saving workspace variables individually?

Hello
Is there a way to save the variables in the workspace separately?
Say the workspace contains 50 variables (all arrays of double) , is there a way to save those 50 variables separately instead of saving them in one mat file?

 Respuesta aceptada

a = 1;
b = 2;
c = 3;
vars = who
vars = 4×1 cell array
{'a' } {'b' } {'c' } {'cmdout'}
for v = 1:numel(vars)
save(sprintf('%s.mat', vars{v}), vars{v})
end
dir
. .. a.mat b.mat c.mat cmdout.mat

2 comentarios

Dave
Dave el 27 de Mzo. de 2023
thanks!
Les Beckham
Les Beckham el 27 de Mzo. de 2023
You are quite welcome.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scope Variables and Generate Names en Centro de ayuda y File Exchange.

Preguntada:

el 27 de Mzo. de 2023

Comentada:

el 27 de Mzo. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by