matlab自动保存图像为需要的格式

saveas(gcf, '<filename>', '<formattype>')
%saveas(gcf, 'p1', 'png')
%saveas(gcf, 'p1', 'jpg')
%saveas(gcf, 'p1', 'fig')

gcf 代表某个 figure 图形 ;

第二个参数是文件名称 , 默认保存在代码所在目录 ;

第三个参数是文件类格式, 这里的文件类型分为 位图格式 和 矢量图格式 ;
example:


t = 0 : 0.1 : 2 * pi;
x = 3 * cos(t);
y = sin(t);
subplot(2,1,1);
plot(x,y);
% 打开 坐标轴
axis on
% 在第一行第二列绘制图形
subplot(2,1,2);
plot(x,y);
% 关闭 坐标轴
axis off
% 将图像保存为图片格式
saveas(gcf, 'p1', 'png')
saveas(gcf, 'p1', 'jpg')
saveas(gcf, 'p1', 'fig')

posted @ 2023-05-14 15:54  Ada_CN  阅读(39)  评论(0编辑  收藏  举报