Alternative to cell2mat
Mostra commenti meno recenti
I have a cell array, f with contents in it.
Is there a way to sort the contents of the cell array using
[B,IX]=sort(f) without having to use cell2mat?
I would like to evaluate it directly.
1 Commento
Walter Roberson
il 4 Dic 2011
Hmmm... what kind of contents? It is, for example, difficult to sort 'hello' against [18.2 13.39 9.44]
Risposte (2)
Fangjun Jiang
il 4 Dic 2011
1 voto
If f is a cell array of strings, you can run sort(f) directly. If you f contains numerical data, what do you try to sort of the size of data is different. You need to provide more details. And what is wrong with using cell2mat()? What is the rational for "evaluate it directly"?
5 Commenti
RDG
il 4 Dic 2011
RDG
il 4 Dic 2011
Fangjun Jiang
il 4 Dic 2011
C={8,7,9}
[d,ind]=sort(cell2mat(c))
C=c(ind)
Fangjun Jiang
il 4 Dic 2011
Should be all low-case 'c'. Smart phone is too smart.
Jan
il 4 Dic 2011
In this case [C{:}] is faster than CELL2MAT.
Walter Roberson
il 4 Dic 2011
[IX,IX]=sortrows(cell2mat(f));
newcell = f(IX);
No mat2cell() required.
Categorie
Scopri di più su Cell Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!