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 Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by