Main Content

Stateflow.TruthTableChart

Tabular representation of state machine for decision logic

    Description

    Use Stateflow.TruthTableChart objects to create truth table blocks that implement combinatorial logic design in a concise, tabular format. Typical applications include decision making for:

    • Fault detection and management

    • Mode switching

    Truth table blocks execute as Simulink® blocks and provide a more direct implementation of decision logic than using truth table functions in Stateflow® charts. 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:

    rt = sfroot;
    table = find(rt,'-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 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). Only variable-size data can change dimension during simulation. For more information, see Declare Variable-Size Data in Stateflow Charts.

    Discrete and Continuous-Time Semantics

    Activation method for the truth table, specified as 'CONTINUOUS', 'DISCRETE', or 'INHERITED'. For more information, see Update Method.

    Sample time for activating the truth table, specified as a 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 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 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 character vector.

    Document link for the truth table, specified as a 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');
    Introduced before R2006a