This question already has an answer here:
- Export Matlab figure as PNG? 5 answers
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:
Fragment from the official Matlab help:
saveas - Save figure or Simulink block diagram using specified format
Syntax
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.