循环里保存图片每次都要弹出很烦. 可以把figure的可视属性设置成off: f=figure('visible','off'); plot(x,y) exportgraphics(f,'figure.png')