- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
set variable to random number.
I want to set variables to random numbers. I tried this. but it is not working
MEnum = 5;
For( i = 1, i = MEnum, i++,
betai = Random uniform.( 30, 50 )
);
When I print this to the log it just keeps giving me random numbers, how do I get 5 different random numbers for beta1 to beta5?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: set variable to random number.
I would do it this way
beta = {};
MEnum = 5;
for (i=1, I<=MEnum,i++,
beta[i] = Random uniform. (30,50);
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: set variable to random number.
I would do it this way
beta = {};
MEnum = 5;
for (i=1, I<=MEnum,i++,
beta[i] = Random uniform. (30,50);
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: set variable to random number.
and change i=MEnum to i<=MEnum
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: set variable to random number.
I tried
beta = {};
For( i = 1, i <= MEnum, i++,
beta[i] = Random uniform.( 30, 50 );
Print( betai );
);
MEnum is based on how many columns are selected. I checked this out and it is working.
but I get this error:
Name Unresolved: Random uniform. in access or evaluation of 'Random uniform.' , Random uniform.( 30, 50 ) /*###*/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: set variable to random number.
I tried
beta = {};
For( i = 1, i <= MEnum, i++,
beta[i] = Random uniform.( 30, 50 );
Print( betai );
);
MEnum is defined above all this and is working fine.
But I am getting this error:
Name Unresolved: Random uniform. in access or evaluation of 'Random uniform.' , Random uniform.( 30, 50 ) /*###*/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: set variable to random number.
Nevermind, I took out your period and it works. I copied without paying attention. thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: set variable to random number.
Very nice lesson, @txnelson . I would also offer this way:
beta = J( MEnum, 1, Random Uniform( 30, 50 ) );