如何在matlab中按降序对单元格数组进行排序?

时间:2014-04-09 16:37:01

标签: arrays matlab sorting cell

enter image description here如何在matlab中按降序对单元格数组进行排序?我有这个代码用于单元格数组

 ra=0;
            rank=cell(50,1);
              for i=1:50
            for j=1:50;
                 if users{j,i}~='-';
                  ra=ra+1;
                end
            end
            rank{i,1}=ra;
            ra=0;
              end

1 个答案:

答案 0 :(得分:0)

l成为您的单元格数组的名称。你可以这样做:

sortedl = num2cell(sort(cell2mat(l,'descend')));

另一种方法是使用:

sortedl = flipud(sortrows(l,1));
相关问题