Application of "csvwrite(filename,M)" with different filename?

조회 수: 2 (최근 30일)
D.Chehov
D.Chehov 2012년 4월 12일
Hello to all,
There are several loop iterations in my code,the result from the first one is used as an input in the second and so on. I'd like to know how to write the results from every loop in a text-file, whose name contains the number of the loop? Also, have you got an idea how to write a command or code that use this text-file as an input for the next loop that follow!
Thank you in advance and regards!
  댓글 수: 1
Jan
Jan 2012년 4월 12일
Usually answers match your problem more exactly, if you post the code and ask an explicit question. Perhaps your problem is the creation of the text file in a specific format. But I assume, you are looking for a method to create the file names dynamically.

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

채택된 답변

Jan
Jan 2012년 4월 12일
See: FAQ: process a sequence of files. And if you are there already, ready the other topics also.
FilePath = tempdir;
for i = 1:10
FileName = sprintf('file%02d.dat', i);
FID = fopen(fullfile(FilePath, FileName), 'w');
if FID == -1, error('Cannot open file for writing'); end
fprintf('%g %g\n', rand(2, 2));
fclose(FID);
end
The reading works equivalently.
Instead of using files to carry the input data, you can use the data directly in the next iteration.

추가 답변 (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