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!