MATLAB: Save a figure with two plots

MATLABplotsave

This seems like it should be very simple, but it doesn't work. I am plotting two lines in a figure, and want to save the figure as an image. However, the handle h is a vector and saveas doesn't like it. I can't find any help with this in the documentation. What am I missing?
h = plot(price,supply,price,demand)
saveas(h,'myplot','png')

Best Answer

Your code is just saving the current axes, you want;
hfig = figure;
hplot = plot(price,supply,price,demand)
saveas(hfig,'myplot','png')