LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Initialize array to default value after every loop iteration

Solved!
Go to solution

Hello,

 

I want to develop a program in which I use the random number generator function to generate 5 random numbers, store them in an array and then output their median. This whole process has to be looped till the user stops. The array after every loop iteration has to be cleared and only the 5 random numbers are to be present in it at any given instance.

 

I am not able to figure out how to flush the array after every loop.

 

Any help will be appreciated. PFA VI.

0 Kudos
Message 1 of 5
(3,204 Views)

I couldn't have your LabVIEW version and hence couldn't see your code. But do you need something like in the attachment?

 Array clear.jpg

Mathan

0 Kudos
Message 2 of 5
(3,180 Views)
Solution
Accepted by topic author ksharshit

gen-5-randoms-loop.png

this generates 5 random numbers per loop iteration,

the array is newly created in every iteration.

 

you could initialize a 5 element array before the for-loop, and then replace the i-th element with the new random number.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 3 of 5
(3,173 Views)

Does the array always have 5 elements inside it after every loop iteration ?

 

Also how did you get that [DBL] between the build array and Median.vi ? Is it right click - create indicator

0 Kudos
Message 4 of 5
(3,171 Views)

@ksharshit wrote:

 

Also how did you get that [DBL] between the build array and Median.vi ? Is it right click - create indicator


there is a option for block diagrams, to display control/indicators as icons, which mathan and i have disabled.

(try a right-mouse on one of your indicators on the block-diagram --> view as icon)

 

<edit>

also note, that mathan's vi generates only one distinct random number per iteration,

but builds a 5-element array from that

</edit>


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 5 of 5
(3,167 Views)