is it possible to plot and save figure in console mode?

using the plot function in -nodisplay mode is possible without error or warning? and the plot can be saved in .pgn format?

Answers (1)

x = 1:10; y = x;
h = plot(x, y);
% Save plot in png format using hgsave
hgsave(h, 'sample.png');

2 Comments

thanks, but I want to display the plot in case of non-command mode. So it would be nice to work well in both cases.
Add before the plot:
try
figure
catch
% do nothing
end

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Asked:

on 28 Jun 2015

Edited:

on 29 Jun 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!