Export Simulink models to publication-quality figures

Note: I have moved my blog to my personal site. The most updated version of this post can be found here.

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.

This entry was posted in LaTeX, Matlab and tagged , , , . Bookmark the permalink.

7 Responses to Export Simulink models to publication-quality figures

  1. Jana says:

    Thanks. This is very much useful to me. Earlier i used to convert from mdl to jpg and then to eps. So quality was very bad. Now it is very good because i get eps directly in vector form. This is very useful for my publication.

  2. Pingback: Produce publication-quality figures in Matlab | Truong's Weblog

  3. welf says:

    Thanks for posting this. I’ve spent the day trying to do exactly the same thing, but I couldn’t get Ghostscript to do the cropping properly for me. I’m not sure if it’s a difference in the versions of Matlab/Ghostscript that I’m running?

    Instead I worked out my own way of cropping the eps files by editing the header information. I’ve posted on my blog about it here:

    Thanks for the inspiration though.

  4. Justin says:

    Brilliant! This saved me a LOT of screwing around. Thank you so much!

  5. arman rashid says:

    thanks a lot for the post. it came as lifesaver for me.

  6. sunil rathod says:

    hi can u tell me how to convert jpeg to .slx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s