MATLAB Answers

struct with timeseries fields to Excel

25 views (last 30 days)
SE
SE on 11 Dec 2019
Answered: Dheeraj Singh on 17 Dec 2019
Hi all,
i have a 1x1 struct with 58 fields (1x1 double timeseries):
Untitled.png
Each timeseries-field has a "Time" and "Data" column, e.g.:
Untitled1.png
So how can I now make an Excel export of the entire struct?
Unfortunately, the following just exports the field names but not the field data:
S=[test_data(:)];
writetable(struct2table(S),'test.xlsx');
Thanks.

  0 Comments

Sign in to comment.

Answers (1)

Dheeraj Singh
Dheeraj Singh on 17 Dec 2019
You can use the following code for implementing the above:
arr = struct2array(test_data);
t = array2table([arr.Time;arr.Data],'VariableNames',{'Time','Data'});
writetable(t,'test.xlsx');

  0 Comments

Sign in to comment.