Main Content

Stateflow.TruthTableChart

Tabular representation of state machine for decision logic

    Description

    Use Stateflow.TruthTableChart objects to implement combinatorial logic design in a tabular format. You can use Truth Table blocks to model decision making for fault detection and management and mode switching. For more information, see Use Truth Tables to Model Combinatorial Logic.

    Creation

    To create a Stateflow.TruthTableChart object, call the function sfnew with the -TT argument. For example, to create a Truth Table block in a new Simulink® model called myModel, enter:

    sfnew -TT myModel

    Alternatively, you can add a new Truth Table block to an existing model by using the function add_block (Simulink):

    add_block("sflib/Truth Table", ...
        "myModel/Truth Table")

    Then, to access the Stateflow.TruthTableChart object, call the find function for the Simulink.Root object:

    table = find(sfroot,"-isa","Stateflow.TruthTableChart", ...
        Path="myModel/Truth Table");

    Properties

    expand all

    Stateflow® API objects have properties that correspond to the values you set in the Stateflow Editor. To access or modify a property, use dot notation. To access or modify multiple properties for multiple API objects, use the get and set functions, respectively. For more information, see Modify Properties and Call Functions of Stateflow Objects.

    Content

    Name of the truth table, specified as a string scalar or character vector.

    Action table for the truth table, specified as a cell array of character vectors.

    Condition table for the truth table, specified as a cell array of character vectors.

    Whether the truth table supports variable-size data, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Declare Variable-Size Data in Stateflow Charts.

    Since R2023a

    Whether the truth table treats output data with a dimension of length 1 as fixed size, specified as a numeric or logical 0 (false) or 1 (true). When this property is true, the truth table treats output data that have at least one dimension of length 1 as fixed size, regardless of whether you specify the data as having variable size. When this property is false, the truth table treats output data as variable size if you specify the data as having variable size.

    Discrete and Continuous-Time Semantics

    Activation method for the truth table, specified as "CONTINUOUS", "DISCRETE", or "INHERITED".

    Sample time for activating the truth table, specified as a string scalar or character vector. This property applies only when the ChartUpdate property for the truth table is "DISCRETE".

    Integer and Fixed-Point Data

    Whether the data in the truth table saturates on integer overflow, specified as a numeric or logical 1 (true) or 0 (false). When this property is disabled, the data in the truth table wraps on integer overflow. For more information, see Handle Integer and Enumeration Overflow for Chart Data.

    Inherited Simulink signals to treat as Fixed-Point Designer™ fi objects, specified as one of these values:

    • "Fixed-point" — The truth table treats all fixed-point inputs as fi objects.

    • "Fixed-point & Integer" — The truth table treats all fixed-point and integer inputs as fi objects.

    Default fimath properties for the truth table, specified as one of these values:

    • "Same as MATLAB Default" — Use the same fimath properties as the current default fimath object.

    • "Other:UserSpecified" — Use the InputFimath property to specify the default fimath object.

    Default fimath object, specified as a string scalar or character vector. When the EmlDefaultFimath property for the truth table is "Other:UserSpecified", you can use this property to:

    • Enter an expression that constructs a fimath object.

    • Enter the variable name for a fimath object in the MATLAB® or model workspace.

    Debugging

    Level of diagnostic action when the truth table is overspecified, specified as "Error", "Warning", or "None". For more information, see Correct Overspecified and Underspecified Truth Tables.

    Level of diagnostic action when the truth table is underspecified, specified as "Error", "Warning", or "None". For more information, see Correct Overspecified and Underspecified Truth Tables.

    Hierarchy

    This property is read-only.

    Machine that contains the truth table, specified as a Stateflow.Machine object.

    This property is read-only.

    Location of the truth table in the model hierarchy, specified as a character vector.

    Whether the truth table has changed after being opened or saved, specified as a numeric or logical 1 (true) or 0 (false).

    Whether the truth table is locked, specified as a numeric or logical 1 (true) or 0 (false). Enable this property to prevent changes in the truth table.

    This property is read-only.

    Whether the truth table is locked, specified as a numeric or logical 1 (true) or 0 (false). This property is equivalent to the property Locked, but is used internally to prevent changes in the truth table during simulation.

    Identification

    Description for the truth table, specified as a string scalar or character vector.

    Document link for the truth table, specified as a string scalar or character vector.

    User-defined tag for the truth table, specified as data of any type.

    This property is read-only.

    Unique identifier, specified as an integer scalar. Use this property to distinguish the truth table from other objects in the model. The value of this property is reassigned every time you start a new MATLAB session and may be recycled after an object is deleted.

    Object Functions

    findIdentify specified objects in hierarchy
    getChildrenIdentify children of object
    dialogOpen properties dialog box
    viewDisplay object in editing environment

    Examples

    collapse all

    Call the function sfnew with the -TT argument to open a new Simulink model that contains an empty Truth Table block.

    sfnew -TT

    Access the Simulink.Root object by calling the sfroot function.

    rt = sfroot;

    Access the Stateflow.TruthTableChart object by calling the find function for the Simulink.Root object.

    table = find(rt,"-isa","Stateflow.TruthTableChart");

    Version History

    Introduced before R2006a

    expand all