Save .fig and .jpg to folders selected earlier
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Hiro Yoshino
2022 年 12 月 2 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!