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

查看:871
本文介绍了在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\to\file\abc1.png','png');
saveas(b, 'path\to\file\abc2.png','png');
saveas(c, 'path\to\file\abc3.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')将带有
句柄h的数字或Simulink框图保存到文件filename.ext。文件的格式由扩展名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天全站免登陆