saving workspace variables individually?

조회 수: 1 (최근 30일)
Dave
Dave 2023년 3월 27일
댓글: Les Beckham 2023년 3월 27일
Hello
Is there a way to save the variables in the workspace separately?
Say the workspace contains 50 variables (all arrays of double) , is there a way to save those 50 variables separately instead of saving them in one mat file?

채택된 답변

Les Beckham
Les Beckham 2023년 3월 27일
a = 1;
b = 2;
c = 3;
vars = who
vars = 4×1 cell array
{'a' } {'b' } {'c' } {'cmdout'}
for v = 1:numel(vars)
save(sprintf('%s.mat', vars{v}), vars{v})
end
dir
. .. a.mat b.mat c.mat cmdout.mat
  댓글 수: 2
Dave
Dave 2023년 3월 27일
thanks!
Les Beckham
Les Beckham 2023년 3월 27일
You are quite welcome.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by