Effacer les filtres
Effacer les filtres

how to save variable value neatly

5 vues (au cours des 30 derniers jours)
xueqi
xueqi le 27 Mai 2013
Hi, I am trying to save variables in matlab and I find that matlab always save all the files related to this this variables. For example, a=b*3. Then I save a. But when I load a, b appears in the workplace too. It is annoying when there are loads of b. Is anyone how to deal with the situation that I only want to store the value of a?

Réponse acceptée

Image Analyst
Image Analyst le 27 Mai 2013
What was your code? If you do
save(fullMatFileName, 'a');
Then is will only save a and no other variables. What did you do? To retrieve
storedStructure = load(fullMatFileName); % Get everything that was stored.
a = storedStructure.a; % Retrieve a.
  1 commentaire
xueqi
xueqi le 27 Mai 2013
Modifié(e) : xueqi le 27 Mai 2013
Yes by doing this
if true
% save(fullMatFileName, 'a');
end
it does only save the variable a. But a is existing in the file named as fullMatFileName. I guess it is a variable must be existing in a mat file instead of being existing independently as a mat file. Is that right?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT-Files 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