Structure Export

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

 채택된 답변

Walter Roberson
Walter Roberson 2011년 11월 10일

3 개 추천

Structure, or structure array?
Structure case:
t = struct2cell(S);
fprintf(fid, '%s,%s,%s,%f\n', t{:});

댓글 수: 2

Brian
Brian 2011년 11월 11일
I'm still pretty new to Matlab so I'm not sure how to tell if it's simply a structure or a structure array. The struct2cell command worked just fine, creating a 4x1x4158 cell. However, I was having trouble with the second command. To obtain a file ID I tried the fopen command, but it doesn't seem to want to create a new file, just open one that already exists.
Walter Roberson
Walter Roberson 2011년 11월 11일
fid = fopen('OutputFile.txt','wt')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

제품

질문:

2011년 11월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by