Save .fig and .jpg to folders selected earlier
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How do I use the full file name from a uigetdir() source earlier in the code to save a plot as both a JPG and FIG file type?
%This is at the start of the code and it updates a text box field with the full file path of the folder in which I
%want the correct plot files to be saved to
properties (Access = private)
JPEGSaveLocation
MATLABFigureSaveLocation
end
% Callbacks that handle component events
methods (Access = private)
% Callback function: JPEGSaveLocationButton,
% JPEGSaveLocationEditField
function JPEGSaveLocationButtonPushed(app, event)
app.JPEGSaveLocation = uigetdir('*', 'Select Folder to save JPEG');
app.JPEGSaveLocationEditField.Value = app.JPEGSaveLocation;
end
% Callback function: MatLabFigureSaveLocationButton,
% MatLabFigureSaveLocationEditField
function MatLabFigureSaveLocationButtonPushed(app, event)
app.MATLABFigureSaveLocation = uigetdir('*', 'Select Folder to save MATLAB Figures');
app.MatLabFigureSaveLocationEditField.Value = app.MATLABFigureSaveLocation;
%This is at the end of the code and it currently saves both file types to
%the folder where the data comes from. I want them to save to the selected
%folders using the paths from above
savefig(ParentFolderPath);
exportgraphics(gca,ParentFolderPath + ".jpg");
0 commentaires
Réponses (1)
Hiro Yoshino
le 2 Déc 2022
I would add some more code in the MatlabFigureSaveLocationButtonPushed function as follows:
saveFileName = "myFileName";
savefig(fullfile(app.MATLABFigureSaveLocation,saveFileName)); % for fig
exportgraphics(gca,app.MATLABFigureSaveLocation,saveFileName + ".jpg"); % for JPEG
0 commentaires
Voir également
Catégories
En savoir plus sur Printing and Saving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!