printing matlab figures to memory
October 28, 2006 11:36 AM   Subscribe

MatLabFilter: Printing figures to memory? I know that I can use the versatile print command to print a figure to a file. But how might I be able to turn a figure into a matrix in matlab's memory?

previously I've printed figures to files then opened those files into memory but this seems like a horrible kludge. any way to turn an onscreen figure directly into a matrix? specifically I'm interested in creating really busy figures using typical matlab handle graphics, but I'd like to periodically flatten the figure into a matrix then add to it continually without bogging matlab down with a million graphic objects that would take an eternity to render. any ideas?
posted by garethspor to Computers & Internet (3 answers total) 1 user marked this as a favorite
 
The getframe command will give you a matrix of the current axes. If you want the entire figure area, you'll want to do something like:

pos = get(gcf,'Position');
I= getframe(gcf,[0 0 pos(3) pos(4)]);

And then to plot the image on the (new) axes,

image(I.cdata)
set(gca,'Position',[0 0 1 1])
axis off

posted by yarmond at 12:14 PM on October 28, 2006


I believe Matlab will wait until it sees a Drawnow, or you otherwise trigger a Drawnow, to render the plot. So if you can avoid pause, getframe, figure, drawnow, or returning to the command line while you're plotting everything, then it will only have to render once. Of course, this doesn't solve any memory issues, just the time issue.
posted by metaculpa at 5:38 PM on October 28, 2006


I meant to say, as well: see here.
posted by metaculpa at 5:38 PM on October 28, 2006


« Older Why can't my girlfriend and I fall asleep together...   |   Donor Fulfillment Newer »
This thread is closed to new comments.