LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I average two arrays with missing values

I have two arrays which I am trying to average with missing values. If I use NaN in one array then on the combined data array it also shows NaN. If I use a '0' as the missing value indicator it will average the data but then the combined array will consider the '0' as a data point. Is there anyway of indicating to labview to passover an element. In addition I need to keep the row and column lengs consistant so I just can't eliminate the element.
0 Kudos
Message 1 of 5
(3,156 Views)
I would use a silly/easy fix and go through the array value by value. If the value is outside an accepted range, replace the value by the last value (you could use an SR for that).
The accuracy of the new average will however strongly depend on the waveform-shape and how often the out-lias values occur.

Patrick de Boevere
0 Kudos
Message 2 of 5
(3,156 Views)
Hi,
I've built a little .vi in LV 6.1 that will decipher the average of the actual data received, i.e. if there's three items, 1.0, Nan, 2.0, then the average is 1.5. I've done it this way, rather than (1+2)/3 = 1, because if you inserted 1.5 as NaN, then it works out correctly, but if you insert 1, the average becomes 1.33333.

Hope it helps
(It's got error handling in too, just in case you manage to produce an input array that is all NaN!)

S.
// it takes almost no time to rate an answer Smiley Wink
Message 3 of 5
(3,156 Views)
thanks, that's great!!
0 Kudos
Message 4 of 5
(3,156 Views)
No problem

Good luck

S.
// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 5 of 5
(3,156 Views)