nan_fft utility functions nan_ifft

NaN Toolbox >> NaN Toolbox > utility functions > nan_grp2idx

nan_grp2idx

Create index vector from a grouping variable.

Calling Sequence

[G,GN] = nan_grp2idx(S)
[G,GN,GL] = nan_grp2idx(S)

Parameters

S:

grouping variable, can be a numeric, or logical vector; a cell vector of strings; or a character matrix with each row representing a group label.

G:

index vector taking integer values from 1 up to the number K of distinct groups

GN:

cell array of strings representing group labels. GN(G) reproduces S

GL:

same as GN, but GL has the same type as S

Description

grp2idx treats NaNs or empty strings in S as missing values and returns NaNs in the corresponding rows of G. GN and GL don't include entries for missing values.

See also

Examples

groups={'30s','40s','30s','40s','40s'}'
[G,GN]=nan_grp2idx(groups)
disp(GN(G))
nan_fft utility functions nan_ifft