LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

deletion of arrays during specific time intervals...how to get it working?

i am trying to calculate the average peak values in a systolic pressure waveform during a specific time interval. for example, every 5 seconds, i want to average out all the peak values in that interval and after calculating the average, i want to delete the array of peak values. however, what i am finding is that the array is always 0 if i use the delete array in my vi. therefore, the average is always NaN, because the array is empty and there is a divide by 0 error....
what should i do? i have been stuck on it for a long time now, thankyou very much"
0 Kudos
Message 1 of 2
(2,104 Views)
It is very difficult to make sense of your diagram, because all the control references are missing, so it is not possible to tell the various data sources apart.

Where is the data coming from? How do you prevent race conditions between the acquisition and analysis parts?

Overall, the diagram is overly complicated and very hard to read. For example clearing the array does not require reading the old array, measuring it's length, followed by "delete from array", followed by writing back to the array. Why don't you just wire an empty array to it? Same result! 🙂

You go to tremedous lenght calculating a simple array average, using numerous property reads and indexing arrays inside FOR loops. There is "mean.vi" that does it in one step. (If you only
have base LabVIEW, it might not be available (?), so use "Sum" and divide by n. No loop needed). To find the largest element in an array, use "Array Max & Min" from the array palette, again in one simple step.

I would highly recommend going over some LabVIEW tutorials or look at some of the shipped examples. Make yourself familiar with basic programming concepts such as auto-indexing at loop boundaries. An "index array" wired to the loop counter is never needed.

I suspect that your problem is due to a race condition between acquisition and analysis code, but there is no way to tell unless you include all control references and also the companion VI that gets the raw data from the instrument.
Message 2 of 2
(2,104 Views)