11-23-2021 10:45 AM
I have a pretty simple task, I'm trying to make an array of 10 random numbers from 0 to 5. However, if a 0 is given from the random number generator, I want it to use the previous array element instead.
This seems to work if the random number type is "Random Number (Range) I64" but it doesn't work if it is "Random Number (Range) DBL". Why is this?
This can be seen in the example VI I uploaded.
In my actual program, it seems to work intermittently. I'm having trouble figuring out why.
Solved! Go to Solution.
11-23-2021 10:58 AM
The odds of getting exactly 0 from a Double is practically 0. The odds of 0 for an integer are 1/6.
11-23-2021 11:12 AM
Makes sense! My actual program I'm using this in also is using double's. I will try a threshold value instead.
11-23-2021 11:14 AM - edited 11-23-2021 11:15 AM
By the way, you can greatly simplify your VI using an Autoindexing tunnel to build your array and a Feedback Node (or Shift Register) to keep the previous value.
11-23-2021 11:47 AM
thank you! Can you do the same if you are referencing a previous iteration of the array with that type of shift register (feedback node)?
11-23-2021 12:38 PM
@downerdce wrote:
thank you! Can you do the same if you are referencing a previous iteration of the array with that type of shift register (feedback node)?
I'm not sure what you are asking for here. A Shift Register and Feedback Node will just return whatever the previous input to it was.
11-23-2021 01:18 PM
When you're doing this to get the value from previous full iteration of a FOR loop...
11-23-2021 02:13 PM - edited 11-23-2021 02:17 PM
@downerdce wrote:
When you're doing this to get the value from previous full iteration of a FOR loop...
Nobody here would be doing "this". (attaching a truncated meaningless picture of useless code!)
Please attach your VI if you want to get help!