In two previous posts, I discussed producing high quality plots from Matlab for publications. Though not as popular, exporting Simulink models to figures for inclusion in publications is sometimes needed. Simply copy-pasting a Simulink model into a graphic editor is usually unsatisfying because the image is bitmap instead of vector and the quality is usually low at screen resolution. In this post, I will give simple steps to export any Simulink model to either an EPS or TIFF image file, of high quality, to be included in publications (typically typeset in LaTeX).
- You don’t need to open the Simulink model you want to export, but you must know its name (or the path to the sub-system/block to be exported). Make sure the model is arranged in the way you want it to appear in the publication.
- By default, the image will have landscape orientation, which often requires you to rotate it when included in the publication. You may want to change the orientation to portrait by the command:
>> orient('mymodel', 'portrait')
where ‘mymodel’ is the name of your Simulink model. If the model is currently open, you can use the function gcs:
>> orient(gcs, 'portrait')
- Issue the command print to export/print the model to an EPS or TIFF file. An EPS file is recommended if possible because it is vector-based, which will give good quality at any resolution. You specify the name of your Simulink model using the switch -s<model-name>; if the model is currently open, you can simply use -s. For example:
>> print -deps -r300 -smymodel myfig.eps
More printing options can be used to get the result you like. For more information, refer to the documentation.
- One problem you may encounter is the large size of the figure, with a large empty background. If the image is bitmap (e.g., TIFF), you can use any graphic software to crop it. If it is EPS, the simplest solution in my opinion is to change the file extension to PS and run the program ps2eps on it. For example:
$ mv myfig.eps myfig.ps
$ ps2eps myfig.ps
ps2eps (distributed with the Ghostscript software package) converts an image to EPS format and in the process, it also crops the image to its bounding-box. Another solution is to use the free program GSView, which has a menu command to calculate and apply the bounding-box.
Now that you have an EPS or TIFF image of the Simulink model, you can use it in your publication in the usual way.