MATLAB Answers

0

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

Asked by Eunice Yang on 14 Feb 2019 at 5:33
Latest activity Answered by Eunice Yang on 15 Feb 2019 at 10:30
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

It depends on the size and what adat you wnt to save......
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.

3 Answers

Answer by Eunice Yang on 15 Feb 2019 at 10:30
 Accepted Answer

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

  0 Comments

Sign in to comment.


Answer by KSSV
on 14 Feb 2019 at 6:18

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) ;

  0 Comments

Sign in to comment.


Answer by Eunice Yang on 14 Feb 2019 at 11:32

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.

  0 Comments

Sign in to comment.