Save figure name as string
Mostra commenti meno recenti
How do I save a file name as a string? hFig is the Figure I want to save and str is the name I want to save this figure as. When I run it i get the below message:
Error using saveas (line 96)
Invalid filename.
str = 'ERP_GRP_1'
saveas(hFig, fullfile(path, [str '.jpeg']));
Risposta accettata
Più risposte (1)
Image Analyst
il 14 Dic 2021
If you have r2020b or later you should use exportgraphics().
And you should not use JPG format unless you're willing to have horrible jpeg compression artifacts.
str = 'ERP_GRP_1';
% Create filename with folder prepended.
folder = pwd; % Or whatever you want.
fullFileName = fullfile(folder, [str, '.png']);
% Save hFig
exportgraphics(hFig, fullFileName);
Categorie
Scopri di più su Printing and Saving in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!