MATLAB: Workspace not saving – just disappearing!

MATLABnot savingworkspace

Hello Community,
I dont understand what is happening here. I am using a line of code to save my workspace – however what happens is the saved workspace doesnt get created, the dialogue box just disappears and nothing is saved. Code as:
[file,path] = uiputfile('*.mat','Save Workspace As');
so when I call this and fill in the filename in the dialogue box – nothing gets saved at all. Variables 'file' and 'path' are created and are added to the workspace, but a copy of all the variables contained in the workspace under a '.mat' file is not created or added to the current parent folder.
Any ideas as to whats going on here?
Regards,
10B.

Best Answer

From the documentation:
  • Note: Successful execution of uiputfile does not create a file; it only returns the name of a new or existing file that you designate.
Add these lines after the uiputfile call:
pf = fullfile(path, file); % Combines ‘path’ & ‘file’
save(pf); % Saves Workspace
(I did not test this code, but it should work.)