Documentation Center

  • Trial Software
  • Product Updates

removeExtraNanSeparators

Clean up NaN separators in polygons and lines

Syntax

[xdata, ydata] = removeExtraNanSeparators(xdata,ydata)
[xdata, ydata, zdata] = removeExtraNanSeparators(xdata,ydata,zdata)

Description

[xdata, ydata] = removeExtraNanSeparators(xdata,ydata) removes NaNs from the vectors xdata and ydata, leaving only isolated NaN separators. If present, one or more leading NaNs are removed entirely. If present, a single trailing NaN is preserved. NaNs are removed, but never added, so if the input lacks a trailing NaN, so will the output. xdata and ydata must match in size and have identical NaN locations.

[xdata, ydata, zdata] = removeExtraNanSeparators(xdata,ydata,zdata) removes NaNs from the vectors xdata, ydata, and zdata, leaving only isolated NaN separators and optionally, if consistent with the input, a single trailing NaN.

Examples

xin = [NaN NaN 1:3 NaN 4:5 NaN NaN NaN 6:9 NaN NaN];
yin = xin;
[xout, yout] = removeExtraNanSeparators(xin, yin);
xout

xout =
  1  2  3  NaN  4  5 NaN  6  7  8  9  NaN

xin = [NaN 1:3 NaN NaN 4:5 NaN NaN NaN 6:9]'
yin = xin;
zin = xin;
[xout, yout, zout] = removeExtraNanSeparators(xin, yin, zin);
xout

xout =
     1
     2
     3
   NaN
     4
     5
   NaN
     6
     7
     8
     9
Was this topic helpful?