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.

 Respuesta aceptada

Jan
Jan el 30 de Nov. de 2018
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

Más respuestas (1)

Categorías

Preguntada:

el 30 de Nov. de 2018

Comentada:

el 1 de Dic. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by