Main Content

Stateflow.TruthTable

Truth table function in chart, state, box, or function

    Description

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

    Creation

    Description

    func = Stateflow.TruthTable(parent) creates a Stateflow.TruthTable object in a parent chart, state, box, or function.

    example

    Input Arguments

    expand all

    Parent for the new truth table, specified as a Stateflow® API object of one of these types:

    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.

    Label for 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.

    Action language used to program the truth table, specified as "MATLAB" or "C". The option "C" is supported only in truth tables in charts that use C as the action language. For more information, see Differences Between MATLAB and C as Action Language Syntax.

    Whether to comment out the truth table, specified as a numeric or logical 1 (true) or 0 (false). Setting this property to true is equivalent to right-clicking the truth table and selecting Comment Out. For more information, see Comment Out Objects in a Stateflow Chart.

    This property is read-only.

    Whether the truth table is implicitly commented out, specified as a numeric or logical 1 (true) or 0 (false). The truth table is implicitly commented out when you explicitly comment out an object that contains it. If the truth table is contained in an atomic subchart or an atomic box, this property is false unless the explicitly commented object is also contained in the atomic subchart or atomic box.

    Since R2023a

    This property is read-only.

    Whether the truth table is commented out, specified as a numeric or logical 1 (true) or 0 (false). This property is true when either IsExplicitlyCommented or IsImplicitlyCommented is true.

    Comment text added to the truth table, specified as a string scalar or character vector. This property applies only when the IsExplicitlyCommented property is true. In the Stateflow Editor, when you point to the comment badge on the truth table, the text appears as a tooltip. When you set the IsExplicitlyCommented property to false, the value of CommentText reverts to "".

    Graphical Appearance

    Position and size of the truth table, specified as a four-element numeric vector of the form [left top width height].

    This property is read-only.

    Whether the truth table graphically intersects a box, state, or function, specified as a numeric or logical 1 (true) or 0 (false).

    Font size for the truth table label, specified as a scalar. The StateFont.Size property of the chart that contains the truth table sets the initial value of this property.

    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.

    Debugger properties for the truth table, specified as a Stateflow.FunctionDebug object with this property:

    • Breakpoints.OnDuring — Whether to set the During Function Call breakpoint, specified as a numeric or logical 1 (true) or 0 (false).

    This property applies only when both the Language property of the truth table and the ActionLanguage of the chart that contains the truth table are "C". For more information, see Set Breakpoints to Debug Charts.

    Example: func.Debug.Breakpoints.OnDuring = true;

    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. This property applies only when the Language property of the truth table is "MATLAB" and the ActionLanguage of the chart that contains the truth table is "C". For more information, see Handle Integer and Enumeration Overflow for Chart Data.

    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.

    This property applies only when the Language property of the truth table is "MATLAB" and the ActionLanguage of the chart that contains the truth table is "C".

    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.

    This property applies only when the Language property of the truth table is "MATLAB" and the ActionLanguage of the chart that contains the truth table is "C".

    Code Generation

    Appearance of the truth table in generated code, specified as one of these values:

    • "Auto" — An internal calculation determines the appearance of the truth table in generated code.

    • "Function" — The truth table is implemented as a separate C function.

    • "Inline" — Calls to the truth table are replaced by code as long as the truth table is not part of a recursion.

    For more information, see Inline State Functions in Generated Code (Simulink Coder).

    Hierarchy

    This property is read-only.

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

    This property is read-only.

    Subviewer for the truth table, specified as a Stateflow.Chart, Stateflow.State, Stateflow.Box, or Stateflow.Function object. The subviewer is the chart or subchart where you can graphically view the truth table.

    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 parent of the truth table in the model hierarchy, specified as a character vector.

    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.

    Session-independent identifier, specified as an integer scalar. Use this property to distinguish the truth table from other objects in the model.

    This property is read-only.

    Unique identifier, specified as an integer scalar. Unlike SSIdNumber, 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
    getParentIdentify parent of object
    getReferencesIdentify references to symbol name
    renameReferencesRename symbol and update references to symbol name
    commentedByIdentify objects that implicitly comment out a graphical object
    dialogOpen properties dialog box
    viewDisplay object in editing environment
    highlightHighlight graphical object
    fitToViewZoom in on graphical object

    Examples

    collapse all

    Add a truth table function in the chart ch. Set its label to "[y1,y2] = f(x1,x2,x3)".

    func = Stateflow.TruthTable(ch);
    func.LabelString = "[y1,y2] = f(x1,x2,x3)";

    Version History

    Introduced before R2006a

    expand all