print an array to .txt
30 次查看(过去 30 天)
显示 更早的评论
Didn't find a good explanation.
Suppose we have an array R=[..,..,..] How to save this single array to a .txt file? Thank you.
2 个评论
Jan
2016-9-26
It depends on the contents of the variable. If it e.g. a nested struct or cell array, you need another approach than for a simple string. How should the created file look like?
采纳的回答
Geoff Hayes
2016-9-26
% open your file for writing
fid = fopen('myTextFile.txt','wt');
% write the matrix
myData = randi(255,10,3);
if fid > 0
fprintf(fid,'%d %d %d\n',myData');
fclose(fid);
end
The above is a very simple example that is based on the examples in the provided link so see that link for more details.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!