slash / after text .txt
3 次查看(过去 30 天)
显示 更早的评论
% open your file for writing
fid = fopen('test.txt','wt');
fprintf(fid,'super\n')
% write the matrix
myData = randi(255,10,3);
if fid > 0
fprintf(fid,'%d %d %d\n',myData');
fclose(fid);
end
This script creates a .txt file of the following format: super, then 10x3 array
The question: how to add "/" after(down) the array? Thank you!
0 个评论
采纳的回答
Massimo Zanetti
2016-9-29
Just print it before closing the file.
% open your file for writing
fid = fopen('test.txt','wt');
fprintf(fid,'super\n');
% write the matrix
myData = randi(255,10,3);
if fid > 0
fprintf(fid,'%d %d %d\n',myData');
end
fprintf(fid,'/');
fclose(fid);
2 个评论
Massimo Zanetti
2016-9-29
This error does not relate to "/". You are not properly opening the txt file. Indeed, I run it and it works, look in the file attached.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Standard File Formats 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!