I want to ascend cell
1 回表示 (過去 30 日間)
古いコメントを表示
hey , I want to ascend the rows based on a specific columns in the cell array . here's an example
The input in work space is
cellmobility{1,1}
x 4
y 2
z 1
g 3
the output i seek in work space is
cellmobility{1,1}
z 1
y 2
g 3
x 4
0 件のコメント
採用された回答
Thomas
2012 年 6 月 18 日
There might be an easier way of doing this but the following should work..
a{1,1}={'x 4';'y 2';'z 1';'g 3'};
a{1,1}
p=cell2mat(a{1,1}); %convertign to mat
check=str2double(cellstr(p(:,3))); % getting col 3, i.e. the num to sort
[l,row]=sort(check); % sorting
out{1,1}=p(row,:); % reorder according to sort
out{1,1}
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!