How to list variables in save() as an array of strings

1 vue (au cours des 30 derniers jours)
alex barrie
alex barrie le 7 Déc 2017
Commenté : alex barrie le 7 Déc 2017
I want to save a list of vars to a mat file, but the list of vars is not known until run time, such as:
vars = ['a', 'b', 'c']; save('fname', vars)
Is this possible?

Réponse acceptée

KL
KL le 7 Déc 2017
use a cell array,
vars = {'a','b','c'};
and then,
save('dummy.mat',vars{:})
  2 commentaires
Stephen23
Stephen23 le 7 Déc 2017
More information on this in the MATLAB documentation:
alex barrie
alex barrie le 7 Déc 2017
The cell array worked, thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Variables 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