Save an image with a different name using GUI
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
hello, I've created using GUIDE a function that allow me do make a graph and modify parameters. I add the button "Save Figure" from the Toolbar Layout but it saves it with the same name than the original figure using by GUI.
I wanted to have a different name using a callback function linked to the save button. However, with the function savefig ('newname.fig') I have the error: Undefined function 'savefig' for input arguments of type 'char'.
0 Commenti
Risposte (1)
Brian Neiswander
il 13 Ago 2015
The function "savefig" was introduced in MATLAB R2013b. If you are using a version earlier than MATLAB R2013b, try using:
saveas(gcf,'newname.fig');
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:
which -all savefig
The output should show something similar to:
<matlabroot>\toolbox\matlab\graphics\savefig.p
where <matlabroot> is the output of the command:
matlabroot
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:
savefig ('newname.fig');
You can now try executing the application again and the "Save" button in the toolbar should generate the file "newname.fig".
0 Commenti
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!