MATLAB: How to dynamically generate a file name for save in MATLAB dynamicfileioMATLABsavestring I do not know the file name at the time of coding, only at run time. Best Answer You're probably tryingfname = 'foobag';save fname variable;To do this correctly, you need to use the "functional" form of save:fname = 'foobar';save(fname, 'variable');In fact, it is true in general that the following two lines are equivalent:command str1 str2 str3command('str1', 'str2', 'str3')This allows one replace any or all of the parameters with dynamically generated strings. This is also useful in commands like PRINT, LOAD, CLEAR, etc.[From the MATLAB FAQ of Ancient Times] Related SolutionsMATLAB: Save selected variables into a file save(fname, 'names', 'onsets', 'durations') MATLAB: How to save variable value neatly What was your code? If you dosave(fullMatFileName, 'a');Then is will only save a and no other variables. What did you do? To retrievestoredStructure = load(fullMatFileName); % Get everything that was stored.a = storedStructure.a; % Retrieve a. Related QuestionHow to save specific workspace variables with UIPUTFILE in MATLABHow to request user input to save figure? uiputfile command does not create the file after clicking ‘Save’
Best Answer