saving workspace variables individually?

1 vue (au cours des 30 derniers jours)
Dave
Dave le 27 Mar 2023
Commenté : Les Beckham le 27 Mar 2023
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?

Réponse acceptée

Les Beckham
Les Beckham le 27 Mar 2023
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 commentaires
Dave
Dave le 27 Mar 2023
thanks!
Les Beckham
Les Beckham le 27 Mar 2023
You are quite welcome.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by