problem with using fprintf
3 次查看(过去 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!