Save figure with a specific name
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ConanTaieb
le 21 Sep 2020
Commenté : ConanTaieb
le 21 Sep 2020
Hello,
I export data using the following code :
[file,filepath,filter] = uigetfile({'*.xlsx'},'Select your data');
filename = fullfile(filepath, file);
[data] = xlsread(filename);
I use the data to generate a figure .png and I save it using "saveas".
h=figure('Color',[1 1 1]);
...
saveas(h,'FIG','png');
How can I automatically save the figure with the same name of the selected file with uigetfile?
Thank you!
0 commentaires
Réponse acceptée
Walter Roberson
le 21 Sep 2020
[filedir, basename, ext] = fileparts(filename);
newname = fullfile(filedir, [basename '.png']);
saveas(h, newname, 'png');
Plus de réponses (0)
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!