How to save Matlab data struct with fields containing char and double to excel

I want to save data from .mat to excel. Any pointers would be appreciated. Thank you!
The data has several struct with fields, I have included the first struct with its fields and values. The fields have both char and double in them. The fields are same for all 222 struct. I want to save all values in all struct against the respective fields in an excel file.
>> data=load('matlab.mat')
data =
struct with fields:
event: {1×222 cell}
>> matlab{1,1}
ans =
struct with fields:
EventType: 'Too many levels'
StartAndEndPoint: [223447 223486]
Levels: [2×6 double]
NumberOfLevels: 2
AllLevelFits: [1×40 double]
ChangePoints: [223447 223471 223486]
Fit: [1×216 double]
CountsExtract: [216×1 double]
TimeExtract: [216×1 double]
TimeEvent: [16×1 double]
TiLow: 2.2348
TiHigh: 2.2349
PkMaxBurst: 0.1093
Area: 75.7931
TiMaxBurst: 2.2348
MeanBurst: 0.0406
Event_all: [16×1 double]

 Accepted Answer

You basically have to extract each field into a cell array (for strings) or numerical array (for the numbers), and then use xlswrite() to send each variable to it's desired place in the workbook. You can't do a whole structure all in one shot, each field needs to be extracted individually and written one at a time.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!