This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Specify Block Properties

For each block in a model, you can set general block properties, such as:

  • A description of the block

  • The block execution order

  • A block annotation

  • Block callback functions

To set block properties, use the Property Inspector. You can set properties in the Properties and Info tabs of the Property Inspector when the block is selected. Alternatively, you can use the Block Properties dialog box. For more information on setting properties, see Setting Properties and Parameters.

Set Block Annotation Properties

In the Property Inspector, use the Block Annotation section to display the values of selected block parameters in an annotation. The annotation appears below the block icon.

Enter the text of the annotation in the text box. You can use a block property token in the annotation. The value for the property replaces the token in the annotation in the model. To display a list of tokens that you can use in an annotation, type % in the text box. The parameters that are valid for the selected block appear. See Common Block Properties and Block-Specific Parameters.

Suppose that you specify the following annotation text and tokens for a Product block:

Multiplication = %<Multiplication>
Sample time = %<SampleTime>

In the Simulink® Editor, the block displays this annotation:

You can also create block annotations programmatically. See Create Block Annotations Programmatically.

Specify Block Callbacks

Use the Callbacks tab to specify block callbacks. Callbacks are MATLAB® commands that you specify that execute when a specific model action occurs, such as when you select or delete a block. For more information on callbacks, see Callbacks for Customized Model Behavior.

  1. Select the block whose callback you want to set.

  2. In Properties tab of the Property Inspector, in the Callbacks section, select the function that you want to assign the callback to. For example, select OpenFcn to specify a behavior for double-clicking a block.

  3. In the text box, enter the command that you want to execute when that block function occurs.

    After you assign a callback to a function, the function displays an asterisk next to it in the list. The asterisks helps you to see the functions that have callbacks assigned to them.

Set a Block Callback Programmatically

This example shows how to use the OpenFcn callback to execute MATLAB scripts when you double-click a block. For example, in a MATLAB script you can define variables or open a plot of simulated data.

To create a callback programmatically, select the block to which you want to add this property. Then, at the MATLAB command prompt, enter a command in this form:

In this example, myfunction represents a valid MATLAB command or a MATLAB script on your MATLAB search path.

Specify Block Execution Priority and Tag

In the Advanced Properties section of the block properties, you can specify the block priority and identify the block by assigning a value to the Tag property.

  • Priority — Specify the execution priority of the block relative to other blocks in the model. For more information, see Assign Block Priorities.

  • Tag — Specify an identifier for the block. Specify text to assign to the block Tag parameter. Setting this property is useful for finding the block in the model by searching or programmatically using find_system. See Find Model Elements in Simulink Models.

Use Block Description to Identify a Block

The Info tab displays information about the block type. The block author provides this description.

You can also enter a description in the Description box to provide information about the block instance.

  • If you add a description, you can set up your model display so that the description appears in a tool tip when you hover over the block. Use Display > Blocks > Tool Tip Options > Description to enable this tool tip.

  • The Description property can help you to find a block by searching. See Find Model Elements in Simulink Models.

Create Block Annotations Programmatically

You can use a block AttributesFormatString parameter to display specified block parameter values below the block. Common Block Properties and Block-Specific Parameters describe the parameters that a block can have. Use the Simulink set_param function to set this parameter to the attributes format that you want.

The attributes format can be any text that has embedded parameter names. An embedded parameter name is a parameter name preceded by %< and followed by >, for example, %<priority>. Simulink displays the attributes format text below the block icon, replacing each parameter name with the corresponding value. You can use line-feed characters (\n) to display each parameter on a separate line. For example, select a Gain block and enter this command at the MATLAB command prompt:


The Gain block displays this block annotation:

If a parameter value is not text or an integer, N/S (for not supported) appears in place of the value. If the parameter name is not valid, Simulink displays ??? in place of the value.

Related Topics

Was this topic helpful?