how to save variable value neatly

1 view (last 30 days)
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?

Accepted Answer

Image Analyst
Image Analyst on 27 May 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 Comment
xueqi
xueqi on 27 May 2013
Edited: xueqi on 27 May 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?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!