How do I save the contents of a structure as a textfile?

4 views (last 30 days)
In my workspace, I have a 1x1 structure called output. Shown on the left are 31 fields in this structure with values. How do I save ALL the content of this structure as a single .xls (or txt or csv) file. For example, ECG_II 1x1 structure contains time and values each with 216372x1 double.
  2 Comments
KSSV
KSSV on 14 Feb 2019
It depends on the size and what adat you wnt to save......
Eunice Yang
Eunice Yang on 14 Feb 2019
The size for each are different. How about if I just want to output ECG_II? How would I save this structure as a txt file?
Screen Shot 2019-02-14 at 12.55.09 AM.png

Sign in to comment.

Accepted Answer

Eunice Yang
Eunice Yang on 15 Feb 2019
I ended up writing something like this for each of the structure:
IDfiAP(:,1)=output.fiAP.time;
IDfiAP(:,2)=output.fiAP.values;
save IDfiAPData fiAP -ascii

More Answers (2)

KSSV
KSSV on 14 Feb 2019
S = struct() ;
S.time = (1:100)' ;
S.values = rand(100,1) ;
S.type = 'Wave form' ;
S.unit = 'mv' ;
S.samplerate = 300 ;
iwant = [S.time S.values] ;
xlswrite('test.xlsx',iwant) ;

Eunice Yang
Eunice Yang on 14 Feb 2019
Thank you for your prompt response. Here's what happens: text.xlsx consists only of time column from 1 thru 100 and values column with random numbers. It's not recognizing the values in the output.ECG_II structure. Please advise. Ty.

Categories

Find more on Variables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!