Setting Data Properties in the Data Dialog Box

What Is the Data Properties Dialog Box?

You use the Data properties dialog box to set and modify the properties of data objects. Properties vary according to the scope and type of the data object. The Data properties dialog box displays only the property fields relevant to the data object you are defining. For example, the dialog box displays these properties and default values for a data object whose scope is Constant and type is Fixed point.

For many data properties, you can enter expressions or parameter values. Using parameters to set properties for many data objects simplifies maintenance of your model, because you can update multiple properties by changing a single parameter.

When to Use the Data Properties Dialog Box

Opening the Data Properties Dialog Box

To open the Data properties dialog box, use one of these methods:

Properties You Can Set in the General Pane

The General pane of the Data properties dialog box appears as shown.

You can set these properties in the General pane.

Name

Name of the data object. Name length should comply with the maximum identifier length enforced by Real-Time Workshop code generation software. You can set this parameter in the Symbols pane of the Configuration Parameters dialog box (see Maximum identifier length in the Real-Time Workshop Reference documentation). The default length is 31 characters and the maximum length you can specify is 256 characters. The name can consist of any combination of alphanumeric and special characters; however, it cannot begin with a numeric character or contain embedded spaces.

Scope

Location where data resides in memory, relative to its parent. You can set scope to one of these values:

Scope ValueDescription
LocalData defined in the current Stateflow chart only.
ConstantRead-only constant value that is visible to the parent Stateflow object and its children.
Parameter

Constant whose value is defined in the MATLAB workspace, or derived from a Simulink block parameter that you define and initialize in the parent masked subsystem. The Stateflow data object must have the same name as the parameter.

See Mask Editor in Simulink software documentation for information on how to assign a parameter to a masked subsystem.

See Sharing Simulink Parameters with Stateflow Charts to learn how to use Simulink block parameters with Stateflow charts.

Input

Input argument to a function if the parent is a graphical, truth table, or Embedded MATLAB function. Otherwise, the Simulink model provides the data to the Stateflow chart via an input port on the Stateflow block. See Sharing Input and Output Data with Simulink Models.

OutputReturn value of a function if the parent is a graphical, truth table, or Embedded MATLAB function. Otherwise, the Stateflow chart provides the data to the Simulink model via an output port on the Stateflow block. See Sharing Input and Output Data with Simulink Models.
Data Store MemoryData object that binds to a Simulink data store, which is a signal that functions like a global variable because all blocks in a model can access that signal. This binding allows the Stateflow chart to read and write the Simulink data store, thereby sharing global data with the model. The Stateflow object must have the same name as the Simulink data store. See Sharing Global Data with Simulink Models.
TemporaryData that persists only during the execution of a function. You can define temporary data only for a graphical, truth table, or Embedded MATLAB function, as described in Defining Temporary Data.
ExportedData from the Simulink model that is made available to external code defined in the Stateflow hierarchy, as described in Sharing Stateflow Data with External Modules. You can define exported data only for a Stateflow machine.
Imported

Data parented by the Simulink model that is defined by external code embedded in the Stateflow machine, as described in Sharing Stateflow Data with External Modules. You can define imported data only for a Stateflow machine.

Port

Index of the port associated with the data object. This property applies only to input and output data. See Sharing Input and Output Data with Simulink Models.

Data must resolve to Simulink signal object

Option that specifies that output or local data explicitly inherits properties from Simulink.Signal objects of the same name in the MATLAB base workspace or the Simulink model workspace. The data can inherit these properties:

For more information, see Resolving Data Properties from Simulink Signal Objects.

Size

Size of the data object. The size can be a scalar value or a MATLAB vector of values. To specify a scalar, set the Size property to 1 or leave it blank. To specify a MATLAB vector, use a multidimensional array, where the number of dimensions equals the length of the vector and the size of each dimension corresponds to the value of each vector element.

The scope of the data object determines what sizes you can specify. Stateflow data store memory inherits all of its properties — including size — from the Simulink data store to which it is bound. For all other scopes, size can be scalar, vector, or a matrix of n-dimensions.

For more information, see Sizing Stateflow Data.

Complexity

Option that specifies whether or not the data object accepts complex values. You can choose one of these settings:

Complexity SettingDescription
OffData object does not accept complex values.
OnData object accepts complex values.
InheritedData object inherits the complexity setting from a Simulink block.

For more information, see How Complex Data Works in Stateflow Charts.

Type

Type of data object. You can specify the data type by:

For more information, see Typing Stateflow Data.

Fixed-Point Data Properties

Properties that apply only to fixed-point data. For a detailed discussion about fixed-point data, see Fixed-Point Concepts in the Simulink Fixed Point User's Guide.

When the Data Type Assistant Mode is Fixed point, the Data Type Assistant displays fields for specifying additional information about your fixed-point data.

If the Scaling is Slope and bias rather than Binary point, the Data Type Assistant displays a Slope field and a Bias field rather than a Fraction length field.

You can use the Data Type Assistant to set these fixed-point properties:

Sign.   Specify whether you want the fixed-point data to be Signed or Unsigned. Signed data can represent positive and negative values, but unsigned data represents positive values only. The default setting is Signed.

Word length.   Specify the bit size of the word that will hold the quantized integer. Large word sizes represent large values with greater precision than small word sizes. Word length can be any integer between 0 and 32. The default bit size is 16.

Scaling.   Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization errors. The default method is Binary point scaling. You can select one of two scaling modes:

Scaling ModeDescription
Binary point

If you select this mode, the Data Type Assistant displays the Fraction Length field, which specifies the binary point location.

Binary points can be positive or negative integers. A positive integer moves the binary point left of the rightmost bit by that amount. For example, an entry of 2 sets the binary point in front of the second bit from the right. A negative integer moves the binary point further right of the rightmost bit by that amount, as in this example:

The default binary point is 0.

Slope and bias

If you select this mode, the Data Type Assistant displays fields for entering the Slope and Bias.

Slope can be any positive real number, and the default slope is 1.0. Bias can be any real number, and the default bias is 0.0. You can enter slope and bias as expressions that contain parameters you define in the MATLAB workspace.

For more information about fixed-point scaling, see Scaling in the Simulink Fixed Point User's Guide.

Calculate Best-Precision Scaling.   Click this button to calculate "best-precision" values for both Binary point and Slope and bias scaling, based on the Limit range properties you specify in the Value Attributes pane of the Data properties dialog box.

To automatically calculate best precision scaling values:

  1. In the Data properties dialog box, select the Value Attributes tab.

  2. Specify Limit range properties.

  3. Select the General tab.

  4. Select the option Calculate Best-Precision Scaling.

Simulink software calculates the scaling values and displays them in the Fraction Length field or the Slope and Bias fields. For more information, see Constant Scaling for Best Precision in the Simulink Fixed Point User's Guide.

Lock output scaling against changes by the autoscaling tool.   Check this box to prevent a Simulink model from replacing the current fixed-point type with a type that the autoscaling tool chooses. See Automatic Scaling in the Simulink Fixed Point User's Guide for instructions on autoscaling fixed-point data.

Showing Fixed-Point Details.   When you specify a fixed-point data type, you can use the Fixed-point details subpane to see information about the fixed-point data type that is currently defined in the Data Type Assistant. To see the subpane, click the expander next to Fixed-point details in the Data Type Assistant. The Fixed-point details subpane appears at the bottom of the Data Type Assistant.

The rows labeled Minimum and Maximum show the same values that appear in the corresponding Minimum and Maximum fields in the Value Attributes pane of the Data properties dialog box. See Checking Signal Ranges and Checking Parameter Values for more information.

The rows labeled Representable minimum, Representable maximum, and Precision show the minimum value, maximum value, and precision that can be represented by the fixed-point data type currently displayed in the Data Type Assistant. See Fixed-Point Concepts in the Simulink Fixed Point User's Guide for information about these three quantities.

The values displayed by the Fixed-point details subpane do not automatically update if you click Calculate Best-Precision Scaling, or change the range limits, the values that define the fixed-point data type, or anything elsewhere in the model. To update the values shown in the Fixed-point details subpane, click Refresh Details. The Data Type Assistant then updates or recalculates all values and displays the results.

Clicking Refresh Details does not change anything in the model; it changes only the display. Click OK or Apply to put the displayed values into effect. If the value of a field cannot be known without first compiling the model, the Fixed-point details subpane shows the value as Unknown. If any errors occur when you click Refresh Details, the Fixed-point details subpane shows an error flag on the left of the applicable row, and a description of the error on the right. . For example, the next figure shows two errors.

The row labeled Minimum shows the error Cannot evaluate because evaluating the expression MySymbol, specified in the Minimum field of the Value Attributes pane, did not return an appropriate numeric value. When an expression does not evaluate successfully, the Fixed-point details subpane displays the unevaluated expression (truncating to 10 characters if necessary to save space) in place of the unavailable value.

To correct this error, you would need to define MySymbol in an accessible workspace to provide an appropriate numeric value. After you clicked Refresh Details, the value of MySymbol would appear in place of its unevaluated text, and the error indicator and error description would disappear.

To correct the overflow error shown for Maximum, you would need to decrease the value in the Maximum field of the Value Attributes pane, increase Word length, or decrease Fraction length (or perform a combination of these changes) sufficiently to allow the fixed-point data type to represent the maximum value that it could have.

Properties You Can Set in the Value Attributes Pane

The Value Attributes pane of the Data properties dialog box appears as shown.

You can set these properties in the Value Attributes pane.

Initial value

Initial value of the data object. If you do not specify a value, the default is 0.0. The options for initializing values depend on the scope of the data object, as follows:

ScopeWhat to Specify for Initial Value
LocalExpression or parameter defined in the Stateflow hierarchy, MATLAB workspace, or Simulink masked subsystem
ConstantConstant value or expression. The expression is evaluated when you update the chart, and the resulting value is used as a constant for running the Stateflow chart.
ParameterYou cannot enter a value. The chart inherits the initial value from the parameter.
InputYou cannot enter a value. The chart inherits the initial value from the Simulink input signal on the designated port.
OutputExpression or parameter defined in the Stateflow hierarchy, MATLAB workspace, or Simulink masked subsystem
Data Store MemoryYou cannot enter a value. The chart inherits the initial value from the Simulink data store to which it is bound.

For more information, see Initializing Data from the MATLAB Base Workspace and Sharing Simulink Parameters with Stateflow Charts.

Save final value to base workspace

Option that assigns the value of the data item to a variable of the same name in the model workspace at the end of simulation (see Using Model Workspaces in the Simulink software documentation).

Limit range properties

Range of acceptable values for this data object. Stateflow software uses this range to validate the data object during simulation. To establish the range, specify these properties:

The largest value you can set for Maximum is inf, and the smallest value you can set for Minimum is -inf.

For more information on entering values for Limit range properties, see Entering Expressions and Parameters for Data Properties.

First index

Index of the first element of the data array. The default value is 0.

Units

Units of measurement that you want to associate with the data object. The string in this field resides with the data object in the Stateflow hierarchy.

Test point

Option that designates the data object as a test point. Enabling this option guarantees that you can observe the data object during simulation (see Working with Test Points in Simulink software documentation). Data objects can be test points if:

Watch in Stateflow Debugger

Option that enables you to watch the data values in the Stateflow Debugger (see Watching Data in the Stateflow Debugger).

Properties You Can Set in the Description Pane

The Description pane of the Data properties dialog box appears as shown.

You can set these properties in the Description pane.

Description

Description of the data object.

Document link

Link to online documentation for the data object. You can enter a Web URL address or a MATLAB command that displays documentation in a suitable online format, such as an HTML file or text in the MATLAB Command Window. When you click the Document link hyperlink at the bottom of the properties dialog box, Stateflow software evaluates the link and displays the documentation.

Entering Expressions and Parameters for Data Properties

You can enter expressions as values for these properties in the Data properties dialog box:

Expressions can contain a mix of parameters, constants, arithmetic operators, and calls to MATLAB functions.

Default Data Property Values

When you leave an expression or parameter field blank, Stateflow software assumes a default value, as follows:

FieldDefault
Initial value0.0
Maximuminf
Minimuminf
Word length16
Slope1.0
Bias0.0
Binary point0
First index0
Size
  • −1 (inherited), for inputs, parameters, and Embedded MATLAB function outputs

  • scalar, for all other data objects

Using Parameters in Expressions

You can include parameters in expressions. A parameter is a constant that you can:

You can mix both types of parameters in an expression.

Using Constants in Expressions

You can use two types of constants in expressions in the Data properties dialog box:

Using Arithmetic Operators in Expressions

You can use these arithmetic operators in expressions in the Data properties dialog box:

Calling Functions in Expressions

In fields that accept expressions, you can call functions that return property values of other variables defined in the Stateflow hierarchy, MATLAB workspace, or Simulink masked subsystem. For example, these functions can return appropriate values for specified fields in the Data properties dialog box:

FunctionReturnsFor Field
MATLAB function sizeSize of input arraySize
Stateflow function typeType of input dataData type
MATLAB function minSmallest element or elements of input arrayMinimum
MATLAB function maxLargest element or elements of input arrayMaximum
Simulink function fixdtSimulink.NumericType object that describes a fixed-point or floating-point data typeData type

  


 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS