matlab裁剪图片空白边缘的示例代码:

clc,clear,close all
x=-20:1:20;
y=-20:1:20;
[x,y]=meshgrid(x,y);
z=x.^2+y.^2;
surf(x,y,z)
colormap(jet)%颜色映射,蓝色开始,红色结束
saveas(gca,'A','jpg')
set(gca,'LooseInset',get(gca,'TightInset'))%裁剪空白区域
saveas(gca,'B','jpg')

A图如下:

1.jpg

B图如下:

2.jpg