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
Another way of saving figures in Matlab is handle them with variables and saving them later.
For example:
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');
Fragment from the official Matlab help:
saveas - Save figure or Simulink block diagram using specified format
Syntax
saveas(h,'filename.ext')
saveas(h,'filename','format')
Description
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.
You can use print
with the -dpng
flag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With