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

2 次查看(过去 30 天)
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