Main Content

Annotate Models

You can use annotations to label your block diagram and provide information about its contents in the canvas. You can also add annotations that perform an action when you click them.

You can create a text annotation or an image annotation.

Text annotations can contain any combination of these elements:

  • Text

  • Images

  • Equations generated using LaTeX and MathML commands

  • Hyperlinks that open a website or run MATLAB® functions

Image annotations can only contain images.

Use image annotations when you want to resize or move an image independently from text.

Create Text Annotations

To create a text annotation:

  1. Double-click the canvas where you want the annotation. The quick insert menu opens. The default option in the quick insert menu is Create Annotation.

    Quick insert menu showing the Create Annotation option

  2. Press Enter.

  3. Type the annotation text.

    • Use the formatting toolbar to edit the text font, font size, font color, or highlight color.

    • To create a bulleted or ordered list, right-click the annotation and select Paragraph > Bullets or Paragraph > Numbering.

    • To align the annotation text, right-click the text and select Paragraph > Alignment.

    To add an image, table, or equation to the annotation, in the formatting toolbar, click Insert Image , Insert Table , or Insert Equation . For more information about adding equations, see Add Equations to Text Annotations.

    The formatting toolbar is above the annotation text. The Insert Image, Insert Table, and Insert Equation buttons are labeled.

    To add a hyperlink, in the annotation, select the content that you want to make interactive. Right-click the selected content and select Hyperlink or press Ctrl+K. For more information about adding hyperlinks, see Add Hyperlinks to Annotations.

Tip

Alternatively, to create a text annotation, in the Simulink® Editor palette at the left edge of the model window, click Annotation . Then, click the canvas and type the annotation text.

To create an annotation using text from another application, drag the text from the application to the canvas.

To paste text from the clipboard into an annotation, right-click the canvas and select Paste.

To create a copy of the annotation, press Ctrl while you click and drag the annotation.

Add Equations to Text Annotations

To add an equation to a text annotation:

  1. In the formatting toolbar, click Insert Equation.

    Annotation formatting toolbar, with the cursor hovering over the Insert Equation button

  2. In the Edit Equation dialog box, enter LaTeX or MathML code to generate equations. For supported LaTeX commands, see Insert LaTeX Equation.

    Edit Equation dialog box with LaTeX code in the Enter equation code box, and a preview of the resulting equations in the Preview box

  3. To format the equation, use the formatting toolbar. You can change the text font, font size, font color, or highlight color.

To edit equation code, double-click the equation in the annotation.

Add Symbols to Text Annotations

To add symbols or Greek letters into the annotation text, type the TeX formatting command that generates these symbols into the annotation text.

  1. Add supported TeX commands to your annotation. For example, add this text:

    \sigma \kappa \mu
    
  2. With the annotation selected, or with the text cursor in the annotation, in the Property Inspector, under Appearance, select Enable TeX commands.

    When you click outside the annotation, the TeX commands appear as symbols in the annotation.

The table shows the TeX characters that you can type directly into the text of a Simulink annotation.

Supported TeX Characters

alpha

beta

gamma

delta

epsilon

zeta

eta

theta

vartheta

iota

kappa

lambda

mu

nu

xi

pi

rho

sigma

varsigma

tau

upsilon

phi

chi

psi

omega

Gamma

Delta

Theta

Lambda

Xi

Pi

Sigma

Upsilon

Phi

Psi

Omega

forall

exists

ast

cong

sim

leq

infty

clubsuit

diamondsuit

heartsuit

spadesuit

leftarrow

uparrow

rightarrow

downarrow

circ

pm

geq

propto

partial

bullet

div

neq

equiv

approx

aleph

Im

Re

otimes

oplus

oslash

cap

cup

supseteq

supset

subseteq

subset

int

in

o

copyright

0

ldots

varpi

times

cdot

vee

wedge

perp

mid

Leftarrow

Rightarrow

Uparrow

Downarrow

prime

nabla

surd

angle

neg

lceil

rceil

lfloor

rfloor

langle

rangle

Create Image Annotations

You can use image annotations to add images to the Simulink canvas that convey information about the model or function as background images for the entire block diagram or for groups of model elements.

To add an image to your model:

  1. In the Simulink Editor palette at the left edge of the model window, click Image.

    Upper left corner of Simulink Window with pointer hovering over the Image button

  2. Click the canvas at the location where you want the image.

    Image icon in canvas

  3. Double-click the image icon in the canvas.

  4. In the file locator that opens, find and open the image you want to add.

  5. If the image that appears in the canvas is too large or too small, to resize it, click and drag one of its corners.

    Tip

    • To resize proportionally, press Shift as you drag.

    • If you resize an image, you can reset it to its original size. Right-click the image and select Format > Restore Size.

To create an annotation using an image from another application, drag the image from the application to the canvas.

To create an annotation using an image file, drag the image file to the canvas.

To paste an image from the clipboard into an annotation, right-click the canvas and select Paste.

To include an image, such as your company logo, in every new model, add the image to your default template. See Create Template from Model.

To create a copy of the annotation, press Ctrl while you click and drag the annotation.

To change the image to a different image, double-click the image. In the file locator that opens, find and open the new image you want to use.

Associate Annotations with Blocks and Areas

You can add a line between an annotation and a block or area in a model. These annotation connectors attach dynamically at both ends, so that they move and resize as necessary to maintain the connection.

To add a connector:

  1. Pause the cursor over the annotation outline where you want the line to start.

    Block diagram with line between an annotation and an input block

  2. When the cursor is a crosshair, drag the line to the block or area where you want the line to end.

Block diagram with one line between an annotation and an input block, and another line between the same annotation and an area

To specify the color or width of an annotation connector, right-click the connector and use the Format menu.

Hide Annotations

You cannot hide an annotation, but you can convert an annotation to markup and then hide the markup.

To convert the annotation to markup:

  1. Right-click the annotation.

  2. From the context menu, select Convert to Markup.

Note

Markup has a light blue background, regardless of the background color you set. If you change markup to an annotation, the annotation returns to the background color you set.

To change markup back to an annotation, right-click the markup and select Convert to Annotation.

To hide the markup in your model, in the Format tab, click Show Markup.

To display hidden markup annotations, in the Format tab, click Show Markup.

In a model reference hierarchy, Show Markup and Hide Markup apply only to the current model reference level.

Add Hyperlinks to Annotations

You can add hyperlinks to annotations that open web pages or run MATLAB functions.

To add a hyperlink to an annotation:

  1. In the annotation, select the content that you want to make interactive.

  2. Right-click and select Hyperlink from the context menu.

  3. In the Hyperlink dialog box, do one of these actions:

    • Select URL Address and enter the web address in the Code box.

    • Select MATLAB Code and enter MATLAB functions in the Code box.

  4. Click OK.

When you click the annotation, the web page you specified opens or the code you specified runs.

You can also associate text or image annotations with callback functions that run:

  • When you load the model containing the annotation (load function)

  • When you programmatically delete an annotation or when you interactively or programmatically close the model (delete function).

  • To associate a load function with an annotation, programmatically set the LoadFcn property of the Simulink.Annotation object to the desired function.

  • To associate a delete function with an annotation, programmatically set the DeleteFcn property of the Simulink.Annotation object to the desired function.

For example, add an annotation to your that modifies the value of the variable x when you load or close the model:

  1. Add an annotation to your model with the text increment x.

  2. To initialize x, enter this command in the MATLAB Command Window.

    x=3;
  3. To get the annotation programmatically, in your model, select the annotation. Then, enter this command.

    an=getCurrentAnnotation;
  4. To specify the load function for the annotation, enter this command.

    an.LoadFcn="x=x+1;";
  5. To specify the delete function for the annotation, enter this command.

    an.DeleteFcn="x=x-1;";
  6. Save the model.

  7. Close the model and check the value of x in the Workspace Browser. The value of x is 2 because the delete function has decreased the value by 1.

  8. Reopen the model and check the value of x in the Workspace Browser. The value of x is 3 because the load function has increased the value by 1.

See Also

Related Topics