Clear Filters
Clear Filters

How to list variables in save() as an array of strings

7 views (last 30 days)
I want to save a list of vars to a mat file, but the list of vars is not known until run time, such as:
vars = ['a', 'b', 'c']; save('fname', vars)
Is this possible?

Accepted Answer

KL
KL on 7 Dec 2017
use a cell array,
vars = {'a','b','c'};
and then,
save('dummy.mat',vars{:})

More Answers (0)

Community Treasure Hunt

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

Start Hunting!