Main Content

Logical and Temporal Assessment Syntax

Simulink® Test™ provides three logical and temporal assessment templates:

  • Logical Assessment Templates

    • Bounds Check — Check maximum and minimum bounds for signals and expressions.

    • Custom — Check if a logical expression holds true for all time steps.

  • Temporal Assessment Template

    • Trigger-Response — Check for a signal response when a trigger is detected.

Logical and Temporal Assessments menu

Bounds Check Assessments

Create bounds check assessments to check if the signals and expressions you test satisfy the boundary condition patterns you specify for them. Boundary condition pattern templates let you test if signals and expressions in terms of boundary values that you specify are:

  • Always less than (or equal to)

  • Always greater than (or equal to)

  • Always inside

  • Always outside

Trigger-Response Assessments

Create trigger-response assessments to verify a signal response when a trigger is detected. A trigger-response assessment requires:

  • Trigger parameter

  • Response parameter

  • Optional Delay parameter

The trigger condition is the condition pattern based on which the response signal is evaluated. There are five trigger condition patterns available:

Trigger Condition PatternBehaviorAvailable Time References
Whenever is trueCheck the response signal continuously whenever the triggering condition is true.N/A
Becomes trueCheck the response signal every time the triggering condition becomes true.Rising edge
Becomes true and stays true for at leastCheck the response signal every time the triggering condition becomes true and stays true for at least the interval specified by the min-time parameter (in s). You also specify an additional time reference parameter at which to evaluate the response signal.Rising edge of trigger or end of min-time
Becomes true and stays true for at mostCheck the response signal every time the triggering condition becomes true and stays true for at most the interval specified by the max-time parameter (in s). You also specify an additional time reference parameter at which to evaluate the response signal.Rising or falling edge of trigger or end of max-time
Becomes true and stays true for betweenCheck the response signal every time the triggering condition becomes true and stays true between the interval specified by the min-time and max-time parameters. You also specify an additional time reference parameter at which to evaluate the response signal.Rising or falling edge of the trigger or end of min-time or max-time

To complete authoring a trigger-response assessment, you specify the response condition pattern and the response condition. There are five response condition patterns available:

Response Condition PatternBehavior
Must be trueThe response condition pattern must be true starting from the time reference parameter to the delay (if it is defined).
Must stay true for at leastThe response condition pattern must stay true for at least the duration specified by the min-time parameter.
Must stay true for at mostThe response condition pattern must stay true for at most the duration specified by the max-time parameter.
Must stay true for betweenThe response condition pattern must stay true for at least the duration specified by the min-time parameter and at most the duration specified by the max-time parameter.
Must stay true untilThe response condition must stay true until the until-condition parameter becomes true within the duration specified by the max-time parameter.

The delay is an optional time interval starting from the time reference parameter to the point where the response condition is expected to be satisfied. You can set the delay to a maximum value or specify a time range in seconds.

Custom Assessments

The custom assessments template allows you to specify logical MATLAB® expressions that do not fit in previous templates. Assessments are meant to evaluate signal properties, so all symbols defined in a custom template must be mapped to signal data (model element or timeseries or a constant scalar value).

Logical and Temporal Assessment Conditions

You can enter MATLAB expressions that include these operators as the assessment conditions:

  • Logical operators: &, |, and ~

  • Relational operators: <, <=, ==, ~=, >=, and >

  • Arithmetic operators: +, -, and * (multiplication by scalar constants only)

  • Cast operators:

The functional forms of the logical, relational, and arithmetic operators are not supported. In addition to operators, you can use the abs function to construct assessment conditions. You can also use the t symbol to construct assessment conditions, which is automatically bound to simulation time. Use of the t symbol as a min-time or max-time parameter in assessment conditions is not supported. Event-based signals are not supported in logical or temporal assessments.

Data Types in Assessment Conditions

Logical and temporal assessment conditions support the built-in data types listed on Data Types Supported by Simulink, with the exception of string. You can also use Simulink.defineIntEnumType. Fixed-point data types are not supported in assessments.

All operands in an assessment condition must be of the same data type. You can use cast operators to change the data type of an operand or change an operand to a symbol and map the symbol to an expression. Read about mapping symbols to expression on Resolve Assessment Parameter Symbols. Read about defining variables for use in an expression on Define Variables in the Assessment Callback Section. When you map a symbol to an expression, the expression must be the same data type as other operands in the assessment condition.

When mapping a symbol to a bus signal or a multidimensional signal, you must map the symbol to only one element from the bus or multidimensional signal. Read about mapping to model elements on Resolve Assessment Parameter Symbols. The data type of the selected element from the bus or multidimensional signal should always be a supported type, and must be the same data type as other operands in the assessment condition.

Define Variables in the Assessment Callback Section

The Assessment Callback section allows you to define variables that you can use in logical and temporal assessment conditions and expressions. You can define variables the same way you do in the MATLAB workspace. This callback also has access to predefined variables that contain data from your test, model, and simulation, such as a signal from a Simulink block. You can define a variable as a function of this data. These objects are available:

Object NameDescription
TestResultThe test case result (sltest.testmanager.TestCaseResult) or test iteration result (sltest.testmanager.TestIterationResult) created from the simulation.
sltest_simoutAn array of simulation outputs ( Simulink.SimulationOutput).
sltest_testCaseCurrent test case object (sltest.testmanager.TestCase).
sltest_bdrootCell array of models simulated by the test case. Can be a harness model.
sltest_sutCell array of systems under test. For a harness, this array contains the component under test.
sltest_isharnessCell array that returns true if sltest_bdroot is a harness model.
sltest_iterationNameName of current test iteration.
sltest_testIterationCurrent test iteration object (sltest.testmanager.TestIteration).

After defining the variables in the callback, you can map the symbols to variables for use in assessment conditions and expressions. Read about mapping a symbol to an expression on Resolve Assessment Parameter Symbols for information on how to map symbols to variables.

The variables created in the Assessment Callback section can only be used in conditions and expressions in the Logical and Temporal Assessments pane. These variables cannot be used in other areas of the Test Manager. The Assessment Callback is saved as part of the test file.

Related Topics