struct2table and data preservation

3 Ansichten (letzte 30 Tage)
Reuben Addison
Reuben Addison am 4 Feb. 2020
Kommentiert: Mohammad Sami am 5 Feb. 2020
I am working with time sensitive data which is in struct form. I imported my data directly using struct2table function so I will be able to use the 'sortrows' function specifically for the table data structure. I then decided to reverser the process by using table2struct, I am wondering if the sequence/sorting will be preserved after converting back to struct. I sorted by date/time. I want to know if the conversion will mess with the sorting.
  3 Kommentare
Stephen23
Stephen23 am 5 Feb. 2020
Reuben Addison's "Answer" moved here:
Thanks, I will try it
Mohammad Sami
Mohammad Sami am 5 Feb. 2020
You can also avoid converting to and from the table. You can sort directly as follows.
Assuming that time is of type date/time or numeric
[~,index] = sort([mystruct.time]);
mysortedstruct = mystruct(index);

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by