Question about 'save' option for workspace variable saving
Afficher commentaires plus anciens
Hello everybody,
I've the follow problem with 'save' function in Matlab:
I would find a method that permit me to save an entire Matlab workspace but with a name coming from a value of a simulation result variable.
For example:
A = 3000;
save ('A');
In this case I got a file saved with A name and not with it's value 3000 as I would.
How can I solve it?
Thank you in advance.
Best regards.
Réponse acceptée
Plus de réponses (1)
It always helps to read the help. If you do, you will see something like this:
save(filename,variable)
So,
save('A',A) % Make a file named A.mat that has variable A
For more information, type this:
help save
3 commentaires
@Knot: Reading the help and doc text is a very good idea, when you have questions about a command:
help save
doc save
Matt Fig
le 12 Sep 2012
Are you saying that you want to save one file per variable, and that each file will be the name of the single variable stored within? Why on earth would you want to do that, when you can simply store all the variables in one file then load them into a structure with the fieldnames given by the variable names?
Here is how to do it, but I seriously wonder why you would do this:
W = who;
for ii = 1:length(W),save(W{ii},W{ii}),end
Catégories
En savoir plus sur File Operations dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!