필터 지우기
필터 지우기

Unable to Sort Mixed Data Type Cell array

조회 수: 3 (최근 30일)
sc1991
sc1991 2017년 12월 7일
댓글: sc1991 2017년 12월 8일
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.

채택된 답변

Guillaume
Guillaume 2017년 12월 8일
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
sc1991
sc1991 2017년 12월 8일
you my friend just saved my day. Thanks a lot for the help. Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by