How to open new text file and how to write on the text file using matlab code?
14 次查看(过去 30 天)
显示 更早的评论
How to open new text file and how to write on the text file using matlab code?
PS: How to go to next line(like we use Enter to go to next line) on the text file using code....can anyone help
0 个评论
采纳的回答
Image Analyst
2015-7-25
Try something like this
fid = fopen(filename, 'wt');
if fid ~= -1
fprintf('This is line 1. Backslash n makes a new line.\n');
fprintf('My result is %f\n, result);
fprintf('My string = %s\n', myString);
fclose(fid);
else
warningMessage = sprintf('Cannot open file %s', filename);
uiwait(warndlg(warningMessage));
end
7 个评论
Image Analyst
2015-7-26
But if you want extra safety and security of saving the old version in the recycle bin instead of blowing it away forever, do this:
recycle on;
delete(filename);
更多回答(0 个)
另请参阅
类别
在 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!