Copy-and-paste is one of the fundamental innovations brought to us by the transition from text-based user interfaces to graphical user interfaces (GUIs). GUIs have been in mainstream use since the introduction of the Macintosh in 1984, so it comes as something of a surprise to learn that Matlab’s copy-and-paste functionality is still deeply broken, twenty years later.
Suppose I want to take a Matlab figure, copy it to the clipboard, and then paste it into a Word document. Furthermore, suppose that I want it to look decent if I then print the Word document. To make this happen, the image that is copied to the clipboard has to have a resolution of at least 300 dots per inch (DPI). Even the first laser printers printed at 300 DPI, and current laser printers typically print at 600 DPI. Typical monitor resolutions are much lower — even a good LCD monitor today is typically only 100 DPI. So copying my figure into Word at the monitor resolution is just not going to cut it. A 100 DPI image looks terrible when printed. I need it to be at 300 DPI at least, and I might very well want it to be higher.
So, when I select “Copy figure…” from my figure’s Edit menu, I want a 300 DPI image of what’s on my screen copied to the clipboard, so then when I go and do Edit > Paste in Word, I get a beautiful 300 DPI image in my Word document. You’d think this wouldn’t be that much to ask, right? I want to take my Matlab figure, paste it into a Word document, and have it not look like crap when printed. Surely, more than twenty years since the advent of the graphical user interface, what-you-see-is- what-you-get, and desktop publishing, this is all old hat for any application worth its salt. Right? Well, not so much…
In Matlab, there is no way to get “Copy Figure” to produce a bitmap that is at any resolution other than the screen resolution (as of R2006b in Windows XP). In the preferences, you can configure several aspects of Matlab’s copy-and-paste behavior, but not the resolution of the final bitmap. You always get it at the screen resolution, which is almost never adequate. Roughly twenty years after this capability should have been part of Matlab, it’s still not present.
On the whole, I think Matlab is a beautiful piece of software. I use it every day, and most of the time I enjoy the heck out of it. It’s very simple and very powerful. But when I’m done analyzing my data, I almost always want to take a figure from Matlab and export it to some other program. This is exactly what copy-and-paste is for, but Matlab’s implementation of copy-and-paste is so broken that I always end up saving my figure to a file and then importing that file into the target application, which takes about ten times as long as copy-and-paste would. If I only did this once a month, it probably wouldn’t make me as insane as it does. But I do it maybe ten times a day, almost every day. Twenty years ago, some wise person at Apple (or maybe Xerox PARC) had exactly the same problem, and invented a solution for it: copy-and-paste. But twenty years later, The Mathworks still hasn’t gotten the memo.
This should be fixed in the next release of Matlab. It should have been fixed a long, long time ago, so fixing it now is really the least The Mathworks could do. If Cleve Moler were here, he would say the same thing.
And another thing: Why do I even have to do Edit > Copy figure to do the copy? Why not just Ctrl-C, like every other application on the planet? In Matlab figures, for some reason, Ctrl-C is used when you decide to edit a figure, and select some element of the figure you want copied to the clipboard. I myself have never used this functionality, and I don’t think I’m the only one. Has The Mathworks looked at how often that’s used compared to “Copy figure”? I would bet almost anything that “Copy figure” is the more commonly used function. If I’m right, it seems like it should be bound to Ctrl-C, not that other function. And in any case, couldn’t Ctrl-C be bound to “Copy figure” if the figure is not being edited?
March 5, 2007 at 11:37 pm
I’m not what you describe is consistent with my current experience using MATLAB Release 11; although I have a vague feeling that I used to have that trouble. Currently I am copying figures and pasting them as Windows Metafiles (whatever that is.) I might have gotten there by pushing the “Windows Metafile” radio button (from the Figure menu bar “Edit>CopyOptions…”). Have you tried that? Also, uncheck the “Match Figure Screen Size” box. I don’t think “Windows Bitmap” is a good choice here. The only issue I have had with this approach is that sometimes the default line weights are too fine when printed and I have to go to the extra trouble of specifying them. On the other hand, I could use some help in inserting the figures into the text in a Word document rather than having them float over the text layer.
March 8, 2007 at 5:31 pm
[...] just discovered the WordPress.com MATLAB feed today. Frinkytown’s complaint about copying and pasting figure reminded me of things I had to do to write my M.S. thesis, and other things I discovered [...]
March 10, 2007 at 6:16 am
This blog is pretty cool. Just wanted to say hi!
April 4, 2007 at 8:09 am
Hey,
I used to run into the same problem.
If you want to copy a matlab figure into word, it looks much nicer if you use the option “preserve information” option in the copy figure options..
If you want to save time, learn how to generate your figure automatically from the code (especially using the “set” function to change all the attributes).
Then at the end of your code you can just use : “print -dmeta” to copy the figure in the clipboard or even “saveas(gcf, ‘fine_name.eps’, ‘psc2′)”
to save as an eps file (or png, jpeg etc..). It kick ass if you use it in combinaison with latex!
You can also find plenty of user friendly functions on internet, to automatically paste your figures into word, excel, power point ect…
cheers
May 1, 2007 at 5:40 pm
Hi and thanks a lot for this valuable feed! I was having a similar problem of printing high resolution images from Matlab. It’s really strange that after all these years, Mathworks still has not fixed very small bugs and problems. At least we know that they’re aware of these (or not?)
May 24, 2007 at 3:22 pm
(Here’s a tongue-in-cheek response to your post)
Matlab copies and pastes just fine to word. I do it all the time.
The proceedure is just about as easy as it could be.
First, you have to click ‘Edit->Copy Options’. Next, you select ‘Figure Copy Template’ from the menu at left, and finally hit the button ‘Settings For PowerPoint’ on the right, hit ‘Apply’ and then ‘Ok’.
Now, you should do ‘Edit->Copy Figure’.
Don’t go pasting it into Word though, it’ll come out really ugly. Instead, open PowerPoint.
Now paste the figure into a full empty slide.
Select the figure, and ungroup it twice. Now that it’s ungrouped, delete the various extra plot lines that make up the axes. Delete the multiple solid-white filled background squares. Delete the extra tick marks. Re-align all the little lines. Scale, rotate and move the text on the axis labels, title, and plot text so that it no longer looks handicapped.
Now select the data points. Caution, this is tricky because the data is now grouped in seemingly arbitrary sets of points. Many of them may sit along the axis. Now change the line-widths and colors to settings that will not cause your paper to be rejected.
Re-group everything.
Scale it all to the proper size (you may need to go back and re-adjust the text at this point).
Copy and paste it into Word. Delete it from Word. This time ‘Paste-Special’ into Word as a Windows Metafile.
Pray your supervisor doesn’t ask you for a trivial change like adding or removing a single data point or trend line.
See, it’s easy. What’s your problem? You must be a lazy user.
And for the record, Cleve Moler is still at the mathworks (or at least he had an active-looking office when I visited a few years back), and he responds to emails. Perhaps this is simply an issue that has yet to be thoroughly requested by users.
I had a much worse time with Matlab for mac, where the copy/paste wouldn’t even work with text, and with matlab for windows, where sometimes the text copy/paste randomly stops working.
I’m also surprised that there is no obvious way to have code save a figure window.
Francis
September 12, 2007 at 1:31 am
I have visited your site 339-times
May 15, 2008 at 7:15 am
do u know the matlab code for interfacing a lcd through parallel port?? working on speech recognition project . if the word say 1 is spoken the details related to it (written in the program) should be displayed. can u help??
July 30, 2008 at 3:10 pm
the first problem can be solved setting properies, ok, but remains the fact that ctrl-c don’t works..
WHY it should open the command winow?
typical exampleof bad interface design. I suggest to mathworks reading jeff raskin’s “user interfaces”.
January 28, 2009 at 4:59 am
Stuffeasy…
Stuffeasy…