03-02-2020 04:37 PM
How do I write a program that generates a specified number of random numbers between 0 and 99 and outputs them as an array. The program should be able to be used as a sub-VI as well.
03-02-2020 05:22 PM
Sounds like a simple FOR loop. If you are using a newer version of LabVIEW (I think 2017 or newer), there is a Random Number (Range).vi in the numeric palette to give you the range requirement.
03-02-2020 05:56 PM
@crossrulz wrote:
Sounds like a simple FOR loop. If you are using a newer version of LabVIEW (I think 2017 or newer), there is a Random Number (Range).vi in the numeric palette to give you the range requirement.
Thanks for that li'l tidbit of information!
03-02-2020 07:24 PM
Unfortunately, the version requirement is 2019 for "Random Number (Range)". I initially started trying to rule it out of 2018 by the numeric online help, but realised the 2019 changes is a better place to check...
It's listed near the bottom of the New VIs and Functions section.
Numeric VIs and Functions
The Numeric palette includes the following new constant and VI:
• Not A Number—Returns the value NaN to the block diagram. [Idea submitted by NI
Discussion Forums member altenbach.]
• Random Number (Range)—Generates a random value from a specified range. You can
use this VI with the following data types: U64, I64, and DBL.
03-03-2020 04:41 AM
Uniform White Noise.vi outputs an array. The amplitude can be set to 99 to get values between 0 and 99...
Presuming 'random' means uniform white noise... Gamma, Poisson, Binominal, Bernouli or Gausian White noise are also available...
03-03-2020 07:23 AM
Something like this would work
The only reason I added the in range function was because you wanted 0-99. You can adjust where needed to get to what you are looking for.
03-03-2020 08:23 AM
You don't need the in range function. The random number generator creates a number x where 0<= x < 1. So 0 to .99999....
So multiplying by a 100 gives you the same result with or without the in range and coerce set the way it is.
Although I think there was a thread in the past year debating whether the actual implementation truly included 0.
If the OP wants an integer between 0 and 99 (typically what these homework problems are looking for, but unclear in this question), then a Round Down (towards 0) should be placed where the in range and coerce is.
03-03-2020 09:16 AM
But why program something?
This VI has the added benifit of a seed input (used if init it true). That means it can potentially produce the same random values if desired. This can be convenient for testing.
03-03-2020 09:20 AM
I think the reason to program something here is to teach the poster how to program. It is very obvious that they need to understand how things work. It is like in math class when you go through all of the work for proofs only to find out when you are all done that there is a way to do the same thing in two steps. Right?
03-03-2020 10:16 AM
@15naj wrote:
How do I write a program that generates a specified number of random numbers between 0 and 99 and outputs them as an array. The program should be able to be used as a sub-VI as well.
I would recommend to use LabVIEW.
This cannot be solved without further information.