LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The array keeps placing the last value from the previous run as the first element in my array.

In my vi I run a picture bow that flickers between grey levels, at the same time I cature a voltage signal and get the rise time and fall time from it. I initialize an array outside of 2 nested for loops and add these rise and fall time means to the array via "replace elements." What is happening is that the last value shown in the rise and fall time mean windows is being placed as the first element in the array. The first element in the array other than the (0,0) position which gets a 0. Can anyone take a look at my vi and tell me why this is happening and how to fix it?
0 Kudos
Message 1 of 2
(2,559 Views)
The reason you are getting a 0 element is due to your initializing the array to 0. If you change that to 111 you will get a diagnal of 111 elements. So this illustrates that you are simply never replacing those elements. I believe your question is why are they not replaced.

To explain why run your VI with highlight execution on and notice the behavior of the 2 loops.

For the first run (i=0) of the outer loop you will run the inner loop 0 times. Therefore you never replace the 0,0 element. The inner loop never runs.

For the second run (i=1) of the inner loop you will run the inner loop 1 time (i=0). So the inner loop will set the inded of row 1 col 0, and then its done.

So I am not sure what exatly you are trying to do, however because of the 0 index o
f loops, you are never getting the 0,0 1,1 etc runs. You may be able to get the behavior you want by running both loops the 9 times, without incrementing the inner loops runs.
0 Kudos
Message 2 of 2
(2,559 Views)