Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Anyone here used Fortran be4?

Status
Not open for further replies.

cwjcwjcwj

Full Member level 5
Joined
Nov 8, 2004
Messages
273
Helped
17
Reputation
34
Reaction score
12
Trophy points
1,298
Activity points
1,714
I am a begineer in Fortran,but I am experienced in Matlab. Just wanna know, what is the main purpose of the following command in Fortran:

igene=2*int(13*secnds(0.0))+1968
call SRand(igene)

Thanks!Actually, I am not really know what is secnds(0.0) and SRand. The rest of them are pretty simple.I know that this is a random number generation.
 

Hi,
Oh, it was at leat 17 years ago I toucht that aqfull language!

Anyway, if I remeber it right, secnds(0.0) will return a value of seconds with 1 decimal accuracy, and Srand is a random generator.

So basicly, what you are doing is to create a good random number with the seed value based on the current time, so you will never have the same seed number for Pseudo Random Generator.

https://gcc.gnu.org/onlinedocs/gcc-3.4.3/g77/Secnds-Intrinsic.html

https://gcc.gnu.org/onlinedocs/gcc-3.4.3/g77/SRand-Intrinsic.html

Hope it helps,

BR,
/Farhad
 

    cwjcwjcwj

    Points: 2
    Helpful Answer Positive Rating
Thanks.So is it possible to convert it to Matlab Language?
 

Hi,
Glad to be able to help. I am not so god with Mathlab, and I have no idea if there is a similar function in MatLab, that returns the current time in seconds, but do a quick search on gogle gave this:

https://www.mathworks.com/access/helpdesk/help/techdoc/ref/clock.html

You maybe able to get the current time in seconds, but I don't think it is as accurate as the fortran function.

Have a look at the random function of MatLab:

https://www.mathworks.com/access/helpdesk/help/techdoc/ref/rand.html#998321

MAybe there is someone else with a better knowledge of Matlab who can give you a better answer.

BR,
/Farhad
 

    cwjcwjcwj

    Points: 2
    Helpful Answer Positive Rating
Hi friends,

In Matlab, use the clock function in order to read the current time.
In order to start the random generator with a “random” seed, use as follows in Matlab version 5 or more:

rand('state',sum(100*clock));

Regards

Z
 

    cwjcwjcwj

    Points: 2
    Helpful Answer Positive Rating
Thanks alot friends.So if it is the case.I will need to write as below to generate 10 random numbers,based on the clock. Pls help to clarify.

rand('state',sum(100*clock));
rand_num=rand(1,10);

Am I right?
 

>>rand('state',sum(100*clock))
>>uniform_random_number = unidrnd(10) // or = random('Discrete Uniform',10)

This generate the discrete uniform random number {1,...,10}.
The first line is only necessary for matlab to generate different random sequence when the program is restarted.

Try to use "help" in matlab to find information.
>> help random
>> help rand
and et.
 

    cwjcwjcwj

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top