Borrar filtros
Borrar filtros

Matlab sort rows based on last column

4 visualizaciones (últimos 30 días)
Sucharitha Chokkappa Gari
Sucharitha Chokkappa Gari el 13 de Oct. de 2020
Editada: Ameer Hamza el 13 de Oct. de 2020
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'

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 13 de Oct. de 2020
Editada: Ameer Hamza el 13 de Oct. de 2020
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, :)

Más respuestas (0)

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by