Main Content

View Values of Parameters Set as Variables

When you specify the value of a Simulink® parameter as a variable or as an expression that contains variables, the Block Parameters dialog box and the Property Inspector display the value of the variable or the expression.

The text box where you enter the parameter value displays the variable or expression on the left and the value on the right.

Note

Numerical values are displayed in the shortG format. For more information about the shortG format, see format.

With this in-place display of parameter values, you can check the value of a parameter in the same text field where you define the parameter.

The value of the variable called x is 40. In the Block Parameters dialog box of a Gain block, the text box for entering the Gain value contains the expression "x+7" at the inner left edge, and the number 47 at the right edge.

To see the value the variable or expression has during simulation, run the simulation and open the Block Parameters dialog box or the Property Inspector. The displayed value is the value of the variable or expression in the simulation at the time step when you open the Block Parameters dialog box or the Property Inspector.

If the variable represents a data type that cannot be evaluated, the data type or class is displayed instead of a value. For example, if the variable represents an object, the class is displayed.

In-Place Parameter Value Display for Different Data Types

What the text field displays depends on the data type and dimensions of the parameter value. The table shows the display according to data type and, where relevant, dimension.

Data Type and DimensionDisplayExample
1-D or 2-D matrix with four elements or fewer

Values of all elements

x=[1,2;3,4];

Text box for a parameter value displays the variable name x on the left, and [1,2,;3,4] on the right

Matrix with more than two dimensions or more than four elementsDimensions and data type
x=[1 2 3 4 5];

Text box for a parameter value displays the variable name x on the left, and <1x5 double> on the right

StringValue
x="position";

Text box for a parameter value displays the variable name x on the left, and "position" on the right

Character vectorValue
x='position';

Text box for a parameter value displays the variable name x on the left, and 'position' on the right

Cell arrayDimensions and data type
x={'a','b','c'};

Text box for a parameter value displays the variable name x on the left, and <1x3 cell> on the right

StructureData type
x.a=1;
x.b=2;
x.c=3;

Text box for a parameter value displays the variable name x on the left, and struct on the right

Object

Class

Note

The class is displayed as a hyperlink. When you click the hyperlink, the MATLAB File Help for the class opens.

Create the BasicClass from the Design Class example.

x=BasicClass;

Text box for a parameter value displays the variable name x on the left, and BasicClass on the right

In-Place Parameter Value Display for Variables Defined in Multiple Workspaces

To see how a variable is evaluated when the same variable name is used to represent different values in different workspaces, see Symbol Resolution Process.

Turn Off In-Place Parameter Value Display

To turn the value display off, in the Simulink Toolstrip, on the Modeling tab, in the Evaluate and Manage section, click Environment, then click Simulink Preferences. Select Editor, then clear Show evaluated value in place.

Note

Settings in the Simulink Preferences are applied to all Simulink windows and persist from one session to the next.

See Also

|