필터 지우기
필터 지우기

Matlab sort rows based on last column

조회 수: 4 (최근 30일)
Sucharitha Chokkappa Gari
Sucharitha Chokkappa Gari 2020년 10월 13일
편집: Ameer Hamza 2020년 10월 13일
This is my data which is in form of cells and I want to sort this based on last column. last column has mixture of 7 digited and 8 digited numbers. how can I sort this.
If im using cell2mat to last column it is showing dimension error
'die4' '3' '0' '3424000' '15884653'
'die4' '3' '0' '3424000' '15884653'
'die4' '4' '0' '174000' '16002122'
'die4' '4' '0' '174000' '16002122'
'die4' '3' '1400000' '3724000' '16700362'
'die4' '1' '5200000' '8624000' '8989534'
'die4' '1' '5200000' '8624000' '9031330'
'die4' '1' '4598880' '8624000' '9141137'
'die4' '1' '4598880' '8624000' '9182932'
'die4' '4' '5300000' '3474000' '9995480'
'die4' '4' '5300000' '3474000' '9995480'

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 13일
편집: Ameer Hamza 2020년 10월 13일
It appears that your data is available in string format. First, convert it to double and then sort
C; % your cell array
C_last = cellfun(@str2double, C(:,end)); % convert last column to numeric format
[~, idx] = sort(C_last);
C_sorted = C(idx, :)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by