The function "savefig" was introduced in MATLAB R2013b. If you are using a version earlier than MATLAB R2013b, try using:
If you are using MATLAB R2013b or later, check if there is a local function named "savefig" that is causing this error. You can do this by executing:
The output should show something similar to:
where <matlabroot> is the output of the command:
If the output is not located inside your <matlabroot> directory, then there is a local function named "savefig" in your path that is interfering with the MATLAB function. You can rename the local "savefig.m" file and function to a different name and try executing your application again.
If the suggestions above do not solve the issue, then try regenerating the callback function. In the "Toolbar Editor" window click on the "View" button to right of "Clicked Callback". You may get a popup dialog asking if you want to replace the current value of the callback with a GUIDE auto-generated callback. If so, click "Yes".
An M-file with an auto-generated callback function will open inside the MATLAB Editor window. Inside this callback function, put the code:
You can now try executing the application again and the "Save" button in the toolbar should generate the file "newname.fig".