필터 지우기
필터 지우기

how to save variable value neatly

조회 수: 5 (최근 30일)
xueqi
xueqi 2013년 5월 27일
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