|On this page…|
You can name a signal. The signal name appears below a signal, displayed as a signal label (for details, see Signal Labels).
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:
Double-click a signal.
An edit box appears next to the signal.
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.
Right-click a signal and from the context menu, choose Properties.
A Signal Properties dialog box opens.
In the Signal Name field, enter a name. Click OK or Apply.
A label showing the name appears on every branch of the signal.
You can also use the MATLAB Command Window to set the name parameter of the port or line that represents the signal:
Select the source block for the line or port.
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')
To change the name of a signal:
Double-click a signal line.
An editing box opens around the label.
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.
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.
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 .
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.
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.
To change the font of a signal label:
Select the signal.
Click Diagram > Format > Font Style.
Select a font from the Select Font dialog box.
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.
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.
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.