在 Matlab 中将绘图保存为 PNG [英] Saving a plot as a PNG in Matlab

查看:105
本文介绍了在 Matlab 中将绘图保存为 PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绘制时间序列的函数,现在我想将其保存为图像,请问如何做到这一点?

I have a function that is plotting a time series, now I want to save this as an image how can this be done please?

function TimeSeriesImages(a, b, c, d, e, f, g, h, i, j, k, l)
x = [a b c d e f g h i j k l];
ts1 = timeseries(x,1:12);
ts1.Name = 'Monthly Count';
ts1.TimeInfo.Units = 'months';
ts1.TimeInfo.Format = 'mmm dd, yy'
ts1.Time=ts1.Time-ts1.Time(1);
plot(ts1)
end

推荐答案

在 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.

这篇关于在 Matlab 中将绘图保存为 PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆