problem with using fprintf
조회 수: 1 (최근 30일)
이전 댓글 표시
I would like to use fprintf to save the following line as a text file.
%%number of points: x
x is a variable and for instance x=25
%%number of points: 25
thank you very much
댓글 수: 2
채택된 답변
Azzi Abdelmalek
2016년 6월 13일
fid=fopen('your_file.txt','w')
x=25
str=sprintf('number of points: %d',x)
fprintf(fid,'%s',str)
fclose(fid)
댓글 수: 4
Walter Roberson
2016년 6월 13일
I would just go for
fid = fopen('your_file.txt', 'w');
x = 25;
fprintf(fid, '%%%%number of points: %d\n', x);
fclose(fid);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!