且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Matlab 中将绘图保存为 PNG

更新时间:2022-11-19 10:11:45

在 Matlab 中保存图形的另一种方法是使用变量处理它们并稍后保存.

Another way of saving figures in Matlab is handle them with variables and saving them later.

例如:

a=bar(...);
b=hist(...);   %some figures
c=plot(...);

saveas(a, 'path	ofileabc1.png','png');
saveas(b, 'path	ofileabc2.png','png');
saveas(c, 'path	ofileabc3.png','png');

来自官方 Matlab 帮助的片段:


Fragment from the official Matlab help:

saveas - 使用指定格式保存图形或 Simulink 框图

saveas - Save figure or Simulink block diagram using specified format

语法

saveas(h,'filename.ext') 
saveas(h,'filename','format')

说明

saveas(h,'filename.ext') 将图形或 Simulink 框图保存为文件filename.ext的句柄h.文件的格式由扩展名 ext 决定.有关更多信息,请参阅 Matlab 帮助.

saveas(h,'filename.ext') saves the figure or Simulink block diagram with the handle h to the file filename.ext. The format of the file is determined by the extension, ext. See Matlab help for more.