In a MATLAB function I am writing, I am generating a figure. The figure is displayed when the function is executed. I need to save the figure as a JPEG image. To do that, I
I had the same problem, and here is what I used to solve it:
set(gcf,'PaperPositionMode','auto') saveas(gcf,'file_to_save','png')
where gcf can be replaced by the handle to the desired figure.
gcf