How to save multiple matrices into multiple text files?

I have a series of matrices like A1,A2,A3,A4.
I want to save them into txt files named like file1, file2, file3, file4 respectively.

 采纳的回答

It is a very bad idea to create variables with indices hidden in the name, see TUTORIAL: How to avoid Eval .
If the variables are store in a cell like A{1}, A{2}, ... the saving works easily using a loop:
for iA = 1:numel(A)
filename = sprintf('file%d.txt', iA);
dlmwrite(filename, A{iA});
end

更多回答(1 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by