0

I am trying to save an image that I generated on a Matlab Gui. I tried following code with a push button:

[Save,savename] = uiputfile('*.bmp','Save Figure As...')
fname=fullfile(savename,Save);
imwrite(handles.axes2, 'fname', 'bmp');

It doesn't work. Can anyone please help?

Taufiq
  • 1
  • 1
  • Please tell us the result rather than simply saying it doesn't work. What result did you expect, and what happened instead? – bodangly May 09 '16 at 02:47

1 Answers1

0

imwrite is for saving image data (as a matrix) to an image file. If you want to save the figure, you will want to use saveas.

If you need to save an image of a specific axes, you can use getframe to save a screenshot of the specified axes, then convert this to an image using frame2im and then use imwrite to save this image data to a file.

frame = getframe(handles.axes2);
im = frame2im(frame);
imwrite(im, fname)
Suever
  • 64,497
  • 14
  • 82
  • 101