Save figure with a specific name
조회 수: 7 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2020년 9월 21일
[filedir, basename, ext] = fileparts(filename);
newname = fullfile(filedir, [basename '.png']);
saveas(h, newname, 'png');
추가 답변 (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!