Unable to Sort Mixed Data Type Cell array
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!