Stuart’s MATLAB Videos

Watch and Learn

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the Original version of the page.

Copying a figure to the clipboard 17

Posted by Doug Hull,

Just a little trick that helps you get MATLAB figures easily into other programs by copying them to the clipboard. Could easily be made into a shortcut on the MATLAB toolbar.

17 CommentsOldest to Newest

Alan Marcel replied on : 1 of 17
Hello Doug! I've followed you at twitter and I've found many interesting MatLab tips. Thank you for sharing your knowledge with us! Keep posting!
oh replied on : 5 of 17
>> print -dmeta
??? Error using ==> inputcheck>LocalCheckDevice at 250
Error using ==> inputcheck>LocalCheckDevice at 250
Illegal device option, '-dmeta', specified.

Error in ==> inputcheck at 45
                [ pj, devIndex ] = LocalCheckDevice( pj, cur_arg, devices );

Error in ==> print at 172
    [pj, devices, options ] = inputcheck( pj, varargin{:} );
My Mac version 10.4.8 and Matlab 7.5.0(R2007b) What's the problem the above?
matt fig replied on : 6 of 17
@oh, As Doug stated above (comment #2), this works on Windows only. Also, you could read the help for PRINT, which specifies the -dmeta flag under the heading: Microsoft Windows system device driver options
frank replied on : 8 of 17
Good trick! It's a pity that the displaying quality of zoom-out figure is poorer than the one obtained by the operation "copy figure" in the menu of figuret.
dhull replied on : 10 of 17
@Lutfy, What would it mean to 'read the figure back from the clipboard into MATLAB'? Doug
Daniel replied on : 11 of 17
Is there a way to get
 print -dmeta 
to preserve the figure color? For example, the following creates a figure with a black background:
colordef black
figure
membrane
print -dmeta
but the copied figure has a white background. Thanks, Dan
Dave Finamore replied on : 13 of 17
Is anyone aware of any recent problems using the toolbar command Edit->Copy Figure to put figures onto the clipboard? That's how I've been doing it for years, but just last week that method started consuming 50% of my processor bandwidth and taking minutes to complete. It doesn't happen on simple plots, but does happen on mesh plots of 200x400 matrices. My workaround is print -dmeta. That works, but Copy Figure essentially hangs the computer. Three different computers, all running R2011b. This could be many things, but it's good to start by finding out if it's a systemic problem or just me. Thanks! Dave
Matti replied on : 14 of 17
Hello Doug, thanks for informative posts. I was wonder that is it possible to copy to clipboard Matlab figure without larger outer borders? Otherwise this code that you presented would work, but if I have one figure which size is whole screen, copy-pasting includes huge borders especially in vertical direction. Usually I need to do some cropping when pasting copied figure to e.g. Powerpoint. Thanks, Matti
Alex replied on : 15 of 17
@Matti You can get rid of the extra space by changing your Preferences. Figure Copy Template > Copy Options > Uncheck Match figure screen size - Alex