% Capture MATLAB images and graphics and place
% them in an image file.


% Make a figure to display a plot
x = 1:10;
plot(x,x.^2)

% Make an image from the figure
% (you can also specify the actual figure number, too)
x = getframe(gcf);

% Display the image in a new figure to verify its appearance
figure
imshow(x.cdata)

% Write the image to a JPEG file
imwrite(x.cdata,'\temp\image.jpg')

% ... OR...

% Write the image to a JPEG file with control over compression
% (use values between 0 and 100, with 100 at highest quality for
%  minimum artifacts)
imwrite(x.cdata,'\temp\image.jpg','Quality',100)
