LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

build array of elements in a for loop

Hello, I have a program where I am taking voltage measurements and computing resistances inside of a for loop. I then want to take these values an place them in individual arrays which are then sent to another subVI to compute the mean and standard deviation. Currently it appears the arrays are getting overwritten and only one value is stored in the array. Please let  me know what I have to do to fix this. Thank you.

I have attached my VI and the area I am talking about is in the case statement inside the big for loop for case 1.

Message Edited by BJalbert on 05-25-2007 09:57 AM

0 Kudos
Message 1 of 5
(4,850 Views)

You are not building any arrays, you just convert a single number to an array with a single element at each iteration of the loop. You need to built your arrays in an initialized shift register or with an autoindexing output tunnel at the right loop boundary.

Do you need to constantly analyze the partial data or do you only need to analyze the full array once acquisition has finished?

0 Kudos
Message 2 of 5
(4,841 Views)
The way I have it set up, I take the mean and std dev at certain points in the loop (controled by the logic block that precedes the for loop). Currently it will calculates those values for the first 10 cycles then after every 1000 cycles and writes the values to a file. I might change it to write the raw data at the given cycles, then write the total mean and std dev. This still brings me to the point of storing all of the data into an array as the loop runs. I'm still not sure how this is done with a shift register since the data is created in a subVi inside of the for loop. I am a novice with Labview so I have not learned the in ands outs of the interface.
0 Kudos
Message 3 of 5
(4,836 Views)

The image shows two possibilities:

Still, you should really simplify your data structures. For example you could have all your 7 results as a single 1D array and built it as a 7xN 2D array, etc. You probably can reduce the clutter on the diagram by 90%! 🙂

It is a nightmare to deal with subVIS containing so many individual connectors.

 

Message Edited by altenbach on 05-25-2007 08:24 AM

0 Kudos
Message 4 of 5
(4,829 Views)
Thanks for your help. I got it working and followed your suggestion for cleaning it up. Have a good one.
0 Kudos
Message 5 of 5
(4,807 Views)