nanclip

Clip vector data with NaNs at specified pen-down locations

Syntax

dataout = nanclip(datain)
dataout = nanclip(datain,pendowncmd)

Description

dataout = nanclip(datain) and dataout = nanclip(datain,pendowncmd) return the pen-down delimited data in the matrix datain as NaN-delimited data in dataout. When the first column of datain equals pendowncmd, a segment is started and a NaN is inserted in all columns of dataout. The default pendowncmd is -1.

Pen-down delimited data is a matrix with a first column consisting of pen commands. At the beginning of each segment in the data, this first column has an entry corresponding to a pen-down command. Other entries indicate that the segment is continuing. NaN-delimited data consists of columns of data, each segment of which ends in a NaN in every data column. Since there is no pen command column, the NaN-delimited format can represent the same data in one fewer columns; the remaining columns have more entries, one for each NaN (that is, for each segment).

Examples

datain = [-1 45 67; 0 23 54; 0 28 97; -1 47 89; 0 56 12]

datain =
    -1    45    67          % Begin first segment
     0    23    54
     0    28    97
    -1    47    89          % Begin second segment
     0    56    12

dataout = nanclip(datain)

dataout =
    45    67
    23    54
    28    97
   NaN   NaN                % End first segment
    47    89
    56    12
   NaN   NaN                % End second segment

See Also

Introduced before R2006a