Structure Export

7 views (last 30 days)
Brian on 10 Nov 2011
I am trying to do something which I feel is pretty simple. I'm trying to export each of 4 fields from a structure to a .txt file. I'd like the text file to be comma delimited. 3 of my fields are character and 1 is double. Is this a fairly simple thing to do?
Thanks, Brian

Accepted Answer

Walter Roberson
Walter Roberson on 10 Nov 2011
Structure, or structure array?
Structure case:
t = struct2cell(S);
fprintf(fid, '%s,%s,%s,%f\n', t{:});
Walter Roberson
Walter Roberson on 11 Nov 2011
fid = fopen('OutputFile.txt','wt')

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by