LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating an random number 2D array with numbers greater than 40

Greetings!

I am trying to create an array 5 columns 20 rows using a random number in 2 for loops. While creating I wish to only use the numbers above 40. I am new on LabView an need some help with this problem.

Thanks!
0 Kudos
Message 1 of 4
(2,963 Views)
The random number function generates a double precision number between 0 and 1.  So you need to perform math on the output to scale it and offset it to the range you want.  You say you only want numbers above 40, but how high above 40 do you want to go?  Do you want them to be integers or real numbers?  All of this will determine what kind of math you need to do on the output.
 
For example, if you want real numbers between 40 and 100, you will need take the random number, multiply by 60, then add 40 to get that result.
0 Kudos
Message 2 of 4
(2,961 Views)
A simple mathscript example to go with what Ravens Fan posted:

max = 100;
min = 40;
y = rand *( max - min) + min;

 
Gives numbers from 40 to 100.

Message Edited by Bill@NGC on 09-30-2007 08:07 PM

0 Kudos
Message 3 of 4
(2,957 Views)
Thank you for your reply it works like a charm!

Newbie 2
0 Kudos
Message 4 of 4
(2,941 Views)