Borrar filtros
Borrar filtros

How can I save .mat files inside a for loop without overlapping?

3 visualizaciones (últimos 30 días)
VB
VB el 22 de Mayo de 2017
Comentada: KSSV el 22 de Mayo de 2017
Hello everyone, I would like to know how can I save several .at files inside a loop without overlapping them. I am trying to save different matrix in every iteration. Thanks for your help!

Respuesta aceptada

KSSV
KSSV el 22 de Mayo de 2017
Why you want to generate multiple .mat files? Check the below two case. You can write all the matrices into a single mat file.
%%If matrices sizes are equal
m = 10 ; n = 9 ; p = 10 ;
A = zeros(m,n,p) ;
for i = 1:p
A(:,:,i) = rand(m,n);
end
save('test.mat','A');
%%if mat4rices sizes are not equal
A = cell(p,1) ;
for i = 1:p
m = randi([1 10],1) ;
n = randi([1 10],1) ;
A{i} = rand(m,n) ;
end
save('test.mat','A');
  1 comentario
KSSV
KSSV el 22 de Mayo de 2017
Vio Bas Commented:
Thank you very much for your question, that was very helpful. It was exactly what I was looking for! Much more efficient than having a huge amount of .mat files. :D

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by