## Stuart’s MATLAB VideosWatch and Learn

### This is machine translation

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

# Copying a figure to the clipboard17

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.

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!
Roy replied on : 2 of 17
Is there a way to do something similar on non-Windows platforms?
dhull replied on : 3 of 17
@Alan, Thanks! @Roy, Nope, sorry!
lzuxz replied on : 4 of 17
Great jobs. But if we have multi figure in one script file,How can we handle the clipboard?
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
dhull replied on : 7 of 17
@lzuxz, The clipboard only supports one item on the stack at a time. Doug
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.
Lutfy replied on : 9 of 17
Is there anyway to read the figure back from the clipboard into matlab?
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
dhull replied on : 12 of 17
@Daniel, Check on 'inverthardcopy'. Doug
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
Lee Kann replied on : 16 of 17
is there any way to put video data into the clipboard?
Stuart McGarrity replied on : 17 of 17
Hi Less, Is the data a video file name or is it a MATLAB multidimensional matrix? Where do you want to send it?