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!

 채택된 답변

Walter Roberson
Walter Roberson 2020년 9월 21일

1 개 추천

[filedir, basename, ext] = fileparts(filename);
newname = fullfile(filedir, [basename '.png']);
saveas(h, newname, 'png');

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Printing and Saving에 대해 자세히 알아보기

질문:

2020년 9월 21일

댓글:

2020년 9월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by