Signal Names and Labels

Signal Names

You can name a signal. The signal name appears below a signal, displayed as a signal label (for details, see Signal Labels).

Choosing a Signal Name

The syntactic requirements for a signal name depend on how the name is used. The most common cases are:

  • The signal is named so that it can be resolved to a Simulink.Signal object. (See Simulink.Signal.) The signal name must then be a legal MATLAB® identifier. Such an identifier starts with an alphabetic character, followed by alphanumeric or underscore characters up to the length given by the function namelengthmax.

  • The signal has a name so the signal can be identified and referenced by name in a data log. (See Export Signal Data Using Signal Logging.) Such a signal name can contain space and newline characters. These can improve readability but sometimes require special handling techniques, as described in Handling Spaces and Newlines in Logged Names

  • The signal name exists only to clarify the diagram, and has no computational significance. Such a signal name can contain anything and never needs special handling.

  • The signal is an element of a bus object. Use a valid C language identifier for the signal name.

  • Inputs to a Bus Creator block must have unique names. If there are duplicate names, the Bus Creator block appends (signal#) to all input signal names, where # is the input port index.

Making every signal name a legal MATLAB identifier handles a wide range of model configurations. Unexpected requirements may require going back and changing signal names to follow a more restrictive syntax. You can use the function isvarname to determine whether a signal name is a legal MATLAB identifier.

To name a signal, use one of the following approaches:

Assign a name from the Simulink block diagram

  1. Double-click a signal.

    An edit box appears next to the signal.

      Note   When you create a signal label, take care to double-click the line. If you click in an unoccupied area close to the line, you will create a model annotation instead.

  2. Enter the desired name, then click somewhere outside the edit box.

    The signal now has the specified name. A label that shows the name appears at the location where you entered it.

For a named multibranched signal, you can put a duplicate label on any branch of the signal by double-clicking the branch.

Assign a Name in the Signal Properties Dialog Box

  1. Right-click a signal and from the context menu, choose Properties.

    A Signal Properties dialog box opens.

  2. In the Signal Name field, enter a name. Click OK or Apply.

    A label showing the name appears on every branch of the signal.

Assign a name from the MATLAB Command Window

You can also use the MATLAB Command Window to set the name parameter of the port or line that represents the signal:

  1. Select the source block for the line or port.

  2. In the MATLAB Command Window, type code similar to the following:

p = get_param(gcb, 'PortHandles')
l = get_param(p.Outport, 'Line')
set_param(l, 'Name', 's9')

Change the Name of a Signal

To change the name of a signal:

  1. Double-click a signal line.

    An editing box opens around the label.

  2. Change the text and then click away from the label.

    All labels update to reflect the change.

Alternatively, you can edit the name in the Signal Properties > Signal name field.

Remove a Signal Name

To remove a signal name, delete all characters in the name, in any label on the signal or in the Signal Properties > Signal name field.

To delete a label without deleting the signal name, click near the edge of the label to select its surrounding box, then press Delete.

Signal Labels

A signal label is text that appears next to the line representing a signal. The signal label displays the signal name. Simulink® creates a label for a signal when you assign it a name. For details, seeSignal Names .

Move Signal Labels

Labels can appear above or below horizontal lines or line segments, and left or right of vertical lines or line segments. Labels can appear at either end, at the center, or in any combination of these locations.

To move a signal label, drag the label to a new location on the line. When you release the mouse button, the label fixes its position near the line. You cannot drag a label away from its signal, but only to a different location adjacent to the signal.

Edit Signal Labels

To edit an existing signal label, select it:

  • To replace the label, click the label, double-click or drag the cursor to select the entire label, then enter the new label.

  • To insert characters, click between two characters to position the insertion point, then insert text.

  • To replace characters, drag the mouse to select a range of text to replace, then enter the new text.

Change the Font of a Signal Label

To change the font of a signal label:

  1. Select the signal.

  2. Click Diagram > Format > Font Style.

  3. Select a font from the Select Font dialog box.

Copy Signal Labels

To copy a signal label, hold down the Ctrl key while dragging the label to another location on the line. When you release the mouse button, the label appears in both the original and the new locations.

Delete Signal Labels

To delete all occurrences of a signal label, delete all the characters in the label. When you click outside the label, the labels are deleted. To delete a single occurrence of the label, hold down the Shift key while you select the label, then press the Delete or Backspace key.

Show Propagated Signal Labels

You can have Simulink pass a signal name to downstream connection blocks. Examples of connection blocks that support signal label propagation include the Subsystem and Signal Specification blocks.

For details, see Signal Label Propagation.

Was this topic helpful?