Borrar filtros
Borrar filtros

Unable to Sort Mixed Data Type Cell array

3 visualizaciones (últimos 30 días)
sc1991
sc1991 el 7 de Dic. de 2017
Comentada: sc1991 el 8 de Dic. de 2017
Hi! I have a cell array with 5 column which has time series data in it. just to give a quick background I initially had 5 variables some double and some string and I concatenated them. To make one cell array. I used the following
new=[Data_Number,Date,num2cell(xyz),num2cell(Software),num2cell(abs_time)]
Now, the reason why i did this was beacuse of this issue
'2017-03-19' 736773.803
'2017-03-19' 736773.8048
'2017-03-19' 736773.834
'2017-03-20' 736773.8374
'2017-03-20' 736773.9578
'2017-03-20' 736773.9617
'2017-03-19' 736773.9687
'2017-03-19' 736774.0073
'2017-03-19' 736774.0122
'2017-03-19' 736774.0174
'2017-03-20' 736774.047
So, here if you see while logging the data it went from 19th to 20 and then came back to 19. So I thought I will use abs time and sort that and change the corresponding 5 columns with it.(Sorry I could show only 2 column here but there are 3 more).
I tried something like this:
sortrows(new,5);
abstime is in 5th column.
But since I have made this cell with different data types I am somehow not able to alter the whole cell based on one column.
Please can any one help me with it.

Respuesta aceptada

Guillaume
Guillaume el 8 de Dic. de 2017
Other solution, convert your cell array to a table. Use sortrows.
tnew = cell2table(new);
sortrows(tnew, 5)
You don't even need to bother with the cell array
tnew = table(Data_Number ,Date, xyz, Software, abs_time);
sortrows(tnew, 5)
  1 comentario
sc1991
sc1991 el 8 de Dic. de 2017
you my friend just saved my day. Thanks a lot for the help. Thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices 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