Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to change the content of file?
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I I would like to change the content of a .txt file via a for loop, if it is possible.
I would like thw first value to be 10 and the last 250, and I want the content to be changed per 10 (I mean for k=10:10:250).
I am importing the .txt file.
How could I do that?
7 个评论
回答(1 个)
Walter Roberson
2020-5-22
filename = 'Document2.txt';
while true
Val = load(filename) + 10;
if Val > 250; break; end
fid = fopen(filename, 'wt') ;
fprintf(fid, '%g\n', Val) ;
fclose(fid) ;
end
Not the way that I would implement myself, but for some reason it is important to you to work this way.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!