MATLAB: How to save variable value neatly

mat filessave load

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?

Best Answer

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.