MATLAB: How to list variables in save() as an array of strings .mat filesave 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? Best Answer use a cell array, vars = {'a','b','c'};and then, save('dummy.mat',vars{:}) Related SolutionsMATLAB: How to save cell array of workspace vars into mat save('test.mat', vars{:})How it works:https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.htmlhttps://www.mathworks.com/matlabcentral/answers/320713-how-to-operate-on-comma-separated-lists MATLAB: Strings Hi,you are nearly there, I believe: suppose you write in your program at the topmyfilename = 'analysed_data1';you just call save withsave(fullfile(path, myfilename));TitusPS: you might also want to take a look at uigetfile ... Related QuestionSaving variables programmatically using list of variable namesStringsStringsDeleting strings in a list
Best Answer