简体   繁体   中英

how to sort a cell array in descending order in matlab?

在此处输入图片说明 how to sort a cell array in descending order in matlab ? I have this code for cell array

 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

let l be the name of your cell array. You can do this:

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

Another way is to use:

sortedl = flipud(sortrows(l,1));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM