how to save variable value neatly

5 次查看(过去 30 天)
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?

采纳的回答

Image Analyst
Image Analyst 2013-5-27
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 个评论
xueqi
xueqi 2013-5-27
编辑:xueqi 2013-5-27
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by