Matlab GUI 界面编程:保存坐标系中的图片
20191206
在表示保存 的按钮 的回调函数中:
h = figure('visible','off');
new_axes = copyobj(handles.axes1,h);%axes1表示坐标系对象
set(new_axes,'Units','normalized','Position',[0.1 0.1 0.8 0.8]);
[filename, pathname] = uiputfile({'*.png';'*.bmp';'*.jpg'},'图片保存为');
if filename ~= 0
file = strcat(pathname,filename);
saveas(h,file);
msgbox('图像已成功保存','确认!','warn');
else
msgbox('操作已取消','确认','warn');
end