saving files in a loop with different names

조회 수: 27 (최근 30일)
h k
h k 2021년 6월 15일
댓글: Stephen23 2021년 6월 15일
hello
in my code created one file is name (info.dat)
I have save every file has created.
File content attached
for k = 1:20
...
% here created (info.dat)
...
end
  댓글 수: 3
h k
h k 2021년 6월 15일
it does not matter
The name of the (info.dat) plus one to 20
example (info1.dat, info2.dat, ...)

댓글을 달려면 로그인하십시오.

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 6월 15일
for k=1:20
...
filename = sprintf('info%d.dat', k);
writematrix(M, filename); % data in M
...
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by