LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sending new values for each repetition of a for loop

dear friends,

as attached , I have random number generator (out of the loop) , and each time the loop starts , I want to have a new value. And save those values to a file. But each time the loop runs , I have the same values instead of new.
I tried to replace shift register but i couldn`t manage it.

Any solution pls?
(i use LV 7.1)

regards
Ci.
0 Kudos
Message 1 of 3
(2,553 Views)
You need to put the random number functions INSIDE the loop.  They generate a random number each time they are called.  They are only called one time before the loop starts.  That value is reused for each iteration of the loop.
0 Kudos
Message 2 of 3
(2,550 Views)


J.Dred wrote:
as attached , I have random number generator (out of the loop) , and each time the loop starts , I want to have a new value. And save those values to a file. But each time the loop runs , I have the same values instead of new.
I tried to replace shift register but i couldn`t manage it.

Per run of the VI, your loop "starts" only once and then repeats the same data 10 times. As Ravens said, if you want to have new random values with each iteration of the loop (not start!), the random number generator belongs inside the loop.
 
There is way too much duplicate functionality. You could really tighten up the code and use a single random number generator in an inner loop. This will simplify everything significantly. See e.g. the modification in the attached image.
 
 
For limited runs such as this, it might be easier to built a 2D array at the output tunnel of the loop and write everything in one operation after the loop finishes. Why do 10 formatting operations, 10 file operations, etc. in near infinitely rapid succession? Writing inside a loop is typically used for extended logging applications on slow loops, whenever you want to make sure you have all the data even if the computer crashes later.


Message Edited by altenbach on 12-16-2007 12:59 PM
0 Kudos
Message 3 of 3
(2,537 Views)