LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiplot graph with missing values fills them with zero instead of NaN

I have a waveform graph with multiple arrays (2D) which has different numbers of points in each array.  LabVIEW finds the array with the most points and then plots all arrays with that many points.  It assigns the missing points a value of zero and displays those zero values.  This means arrays with fewer points than the maximum will have values of zero appear in their plots.  This can be avoided by filling in missing points with NaN.  I am acquiring data in a loop and displaying it which requires continuous determination of the number of actual points and filling in of missing points with NaN.  Not difficult, but this could be avoided if LabVIEW would fill missing points with NaN instead of with zero.  Any way to have this happen automatically ?
 
Steve
 
0 Kudos
Message 1 of 4
(2,692 Views)
The graphs are not filling in the zeros. The Build Array is doing that. When you connect two different size arrays to a Build Array block, the resulting array will be sized to accomodate the largest of the input arrays. It does this separately for each dimension. The value filled in is the default value for the datatype, which is zero for numeric datatypes.

If you want NaN for the non-plotting characteristic, initialize all the arrays to the largest possible size with NaN and use Replace Array Subset to put the actual data into them. This also eleiminates any memory reallocations during the run.

Lynn
0 Kudos
Message 2 of 4
(2,685 Views)

This is really outside of the graphing, and is simply the behavior of LabVIEW.  If you take 2 different sized arrays, LabVIEW simply pads the smaller array with the defualt data for that data type.

For numerics you get 0, for an array of strings you get an empty string, and for a complex cluster you get all their defaults.

To work around this you will need to do teh size checks on your own, and then replace the end of the arrays with an array of NaNs.  There are a few ways to do that, but they are all pretty straight forward.

0 Kudos
Message 3 of 4
(2,683 Views)
You can also consider using an XY graph so you don't have to do additional data manipulation. See attached for comparison.
0 Kudos
Message 4 of 4
(2,682 Views)