Save an image with a different name using GUI
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Brian Neiswander
el 13 de Ag. de 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 comentarios
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!