I regularly have to export many figures (hundreds) into a single file. Currently I use
print('-dpsc2', outfile, '-append');
My code uses a single hidden figure that is being re-used for each new figure.
Now, the problem is that I can achieve a maximum export speed of around 8 figures per second. In R, you can easily plot around 200 figures per second. Does anyone have any suggestions how to (substantially) speed up MATLAB's exporting capabilities?
Jan
I feel your pain. This issue is also why the getframe
function for generating movies is so inefficient. The only way I know around it is to write a simpler function that calls the low-level hardcopy
function. Here's an example of this for image-based graphics along with some caveats. The hardcopy
function supports both the 'dpsc2' and 'append' options that print
does:
hardcopy(gcf,'outfile.ps','-dpsc2','-append');
Whereas print(gcf,'-dpsc2', 'outfile.ps', '-append');
takes about 0.12 seconds, the above takes only 0.004 seconds on my machine!
If you do help hardcopy
you won't get very much information. However, if you need to reverse engineer anything you can read the code for print
(edit print
) or the various private functions it calls (e.g., edit private/render
, edit private/paperfig
, edit private/ghostscript
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With