Save figure with a specific name

21 visualizaciones (últimos 30 días)
ConanTaieb
ConanTaieb el 21 de Sept. de 2020
Comentada: ConanTaieb el 21 de Sept. de 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!

Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Sept. de 2020
[filedir, basename, ext] = fileparts(filename);
newname = fullfile(filedir, [basename '.png']);
saveas(h, newname, 'png');

Más respuestas (0)

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by