saving workspace variables individually?

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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeScope Variables and Generate Names についてさらに検索

質問済み:

2023 年 3 月 27 日

コメント済み:

2023 年 3 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by