MATLAB: Saving work space with a name from a variable

MATLABsave function

I want to save all the variables of the work space, with the name from variable.
I've tried using
filename = test.value;
save (filename)

Best Answer

Try this:
filename = sprintf('%s.mat', test.value); % where test.value is a string variable.
save(filename);