I am writing my Thesis report using LaTeX. I have to explain about a few models that I created in Simulink in my report. I do not know how to import these Simulink models into LaTeX. Can someone help me out with this?

  • I think you have two options: (1) make a snapshot and insert the picture in your LaTeX file or (2) export the Simulink model to HTML, then convert to LaTeX: see here for this last step.
    – Count Zero
    Jun 7 '13 at 12:24

You can do the following; I use Matlab 2013, but I suspect that can also be done in older versions.

  1. Go to File >> Print, then click on Print.
  2. Under Device option, write -dpdf.
  3. Under Send to, you have a choice of two radio buttons; select File.
  4. Press Print; a dialog box will prompt you to choose a path for the file.

Then, in LaTeX, simply use \includegraphics from the graphicx package to insert the pdf you have just saved.

Note: In my experience, most people tend to insert Simulink diagrams as raster-graphics images of dimensions so small that the model is illegible, even when you zoom in on it. That problem is easily obviated by using a vector-graphics format (e.g. pdf), which I urge you to do.

  • Take note that converting the block to pdf gives you some white spaces around the figure. Jun 7 '13 at 13:06
  • @HasanZakeri Yes. That's what I was trying to fix. Matlab/Simulink doesn't seem to offer much flexibility in this regard. The only workaround is to modify the paper size option in the Print window.
    – jub0bs
    Jun 7 '13 at 13:08
  • 1
    Or remove the surrounding white space with external tools, eg. ghostscript :) Jun 7 '13 at 16:39
  • I sometimes use Adobe illustrator to crop pdf files.
    – Ali
    Nov 9 '13 at 12:16

First, save your Simulink model as a figure using Matlab command:




following the directions in this MathWoks link.

In you LaTeX file use (if you saved your Simulink model as an eps file):


Also, this site can be of interest.

  • This works only for figures. The actual model cannot be saved this way.
    – Count Zero
    Jun 7 '13 at 12:58
  • @CountZero: Yes. I write in the answer (if your saved your Simulink model as an eps file). Thanks.
    – user13907
    Jun 7 '13 at 13:02
  • 1
    @Papiro: Thanks, especially for the quick response.
    – Martin Scharrer
    Jun 7 '13 at 13:35

I always use this Mathworks code piece. It removes additional space and works with all figures, I encountered.

  • 2
    Unfortunately, it works with figures not simulink models
    – percusse
    Jun 7 '13 at 13:51

Snapshot of a Simulink model:

  • Open the Simulink system which you would like to print to file.
  • Switch to the Matlab application and run the following code:
    • print -dpdf -s <outputFileName>.pdf %vector format
    • print -dpng -r225 -s <outputFileName>.png %raster format

For vector format: I'm using r2013b, which has pdf capability despite the documentation completely omitting it. Your usage may vary.

For raster format: The default resolution, -r90 can be terrible. Look for washed out connection lines. I found this to occur straight through -r200 when creating .png files.

Snapshot of a Stateflow model:

  • Open the Stateflow system which you would like to print to file.
  • Switch to the Matlab application and run the following code:
    • sfprint(gcs, 'png', '<outputFileName>.png')

For vector format: sfprint does not yet have .pdf output capability. You'll need to use .eps or .svg and a converter. Packages exist within the latex environment to make the conversion. Even so, you may not want latex to convert each time you compile. [See Feature Requests, below.]

For raster format: sfprint does not yet have an option to specify resolution. Even so, I believe this command still provides improved resolution over the File --> Print method.

.PDF Autocrop

To crop your .pdf down to its minimum margins, use the following code on the output .pdf from print:

  • !pdfcrop <outputFileName>.pdf <outputFileName>.pdf

Feature requests

In order to improve the process of exporting images from Mathworks products to a latex environment, I have recently requested that the Simulink and Stateflow teams consider the incorporation of additional functionality to the print and sfprint functions in future releases.

From what I understand, these functions have seen improvements over the past few years already, and I would thus consider them still open to additional development.

I requested the following features:


  • option to automatically crop margins/whitespace.
  • option to specify margins/whitespace of crop option.


  • option to print to .pdf. [option already exists in print].
  • option to specify raster image resolution. [option already exists in print].
  • option to automatically crop margins/whitespace.
  • option to specify margins/whitespace of crop option.

Contact Mathworks with additional insight.

My scope only considered pdflatex. Additional input from the community would likely be useful. Many of you may have needs which are not clear to me which would be better represented yourself. Your submissions would also demonstrate that support for the development of these features would be worthwhile.

To: US MathWorks Support <support@mathworks.com>
Re: Specifying image resolution with sfprint [ ref:_00Di0Ha1u._500i0THMmD:ref ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.