GROUP2CELL - group values into cells
C = GROUP2CELL(V,G) returns a N-by-1 cell array in which the values V are grouped as row vectors into separate cells according to the values in G. Both G and V should have the same number of elements. N is the number of different values in G. Each cell in C is a row vector.
[C,GR] = GROUP2CELL(V,G) also returns the groups in GR, so that C{i} = V(G==GR(i)).
The grouping variable can be a cell array of strings.
Examples:
[C, GG] = group2cell([1 2 3 4 5 6],[1 6 2 1 6 1]) ;
% returns the cell array {[1 4 6] ; [3] ; [2 5]} in C and [1 2 6] in GG
years = [1956 1978 1982 1987 2001 2006] ;
temp = {'normal','cold','hot','normal','cold','hot'} ;
C = group2cell(years,temp)
See also MAT2CELL, CELLFUN, CAT
and NONES, COUNTMEMBER (on the Matlab File Exchange)
Cita come
Jos (10584) (2025). GROUP2CELL (https://www.mathworks.com/matlabcentral/fileexchange/11192-group2cell), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxCategorie
Tag
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
Versione | Pubblicato | Note della release | |
---|---|---|---|
1.0.0.0 | added functionality of grouping variable to be a cell array of strings |