MATLAB: Is there a way to save matlab file with a name given by input

matlab filesave

HiHi! I'm creating an user interface with App Designer! My code runs and doesn't give problems, but I'd like to save my app with a name that is given by input from user. My input (that is found in a function of a button) is:
app.code_patient = inputdlg('Insert code of patient to save file with name:');
This works but I'd like that the name of matlab file is this input followed by '*.mat'. I tried to insert:
save app.code_patient.mat
but in this case matlab saves my results with the name 'app.code_patient.mat' and not with the name of given input.

Best Answer

Use function form, not command form, when you call save. See the last entry in the Description section on the save documentation page and the first entry in the Examples section on that page for examples of the difference.