Use of num2str to name xml-files in a loop
조회 수: 14 (최근 30일)
이전 댓글 표시
Hello,
I'm using a code to write xml-files for some data. The code is:
fid = fopen('file.xml', 'w');
if fid == -1; error('Cannot open file for writing'); end
fprintf(fid, 'Hello ');
fprintf(fid, '%g, ', x(1:end-1));
fprintf(fid, '%g', x(end));
fprintf(fid, ' This is the data.');
fclose(fid);
Since I need to write more than one xml-file, I would like to do it with a loop. My problem is that I need to name each file, e.g. file1.xml, file2.xml and so on. I have tried to do this with a num2str command in a loop, but I can't get it to work. Is there anyone out there who can help me with this problem?
Hope to hear from someone.
//Martin.
댓글 수: 0
채택된 답변
추가 답변 (1개)
Martin
2012년 5월 15일
댓글 수: 2
Walter Roberson
2012년 5월 15일
You would probably have more success if you opened the file for writing rather than reading.
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!