Main Content

Collect Relational Boundary Coverage for MinMax Block

This example shows how to view and interpret relational boundary coverage results for a MinMax block in three different cases.

Open Model

Open the model.

modelName = "slcoverageMinMax";
open_system(modelName);

The slcoverageMinMax model includes three Constant blocks connected to a MinMax block with the Function parameter set to min. In this example, you look at relational boundary coverage results for three different sets of inputs:

  • Case 1: scalar inputs

  • Case 2: same-size vector inputs

  • Case 3: mixed-size inputs

In each case, the model is using the default data type of double, which is a floating-point data type.

Collect Coverage for Three Scalar Inputs

The first case for the MinMax block is when all the input signals are scalar. The slcoverageMinMax model already uses scalar values for the Constant blocks, so you do not need to make changes for this case. Simulate the model, and then highlight the coverage results by using cvmodelview.

scalarDoubleOut = sim(modelName);
cvmodelview(scalarDoubleOut.covdata);

Click the MinMax block named Minimum and look at the relational boundary table.

The first row of the relational boundary table is input1 - min(inputs after input 1). The relational boundary analysis takes the miniumum of input2 and input3 and subtracts the result from input1. Simulink Coverage then compares the result with the relational boundary range [-tol 0] and reports whether the result falls in that range. In this case, the result for input 1 does not fall in the range for any time step, so the report displays missing coverage. For floating-point inputs, the relational boundary for inputs before input i is not inclusive of zero, while the relational boundary for inputs after input i does include zero. You can specify the values for floating-point tolerance in the Coverage pane of the Configuration Parameters dialog box.

In the relational boundary table, the denominator of the second column in each row indicates the number of time steps for which that input was the minimum. For example, the third relational boundary, input 2 - min(inputs after input 2) has a denominator equal to 2, which means that input 2 was the minimum value for two time steps. The numerator indicates the number of time steps where the difference between input 2 and the minimum of inputs after input 2 falls in the indicated range. For the case of input 2, for both time steps that input 2 is the minimum value, the difference between input 2 and input 3 falls between the tolerance and zero.

Collect Coverage for Three Same-Size Vector Inputs

If you have vector inputs to a MinMax block, the block reports relational boundary coverage for each element of each vector.

Create a Simulink.SimulationInput object and use setBlockParameter to set the values of Constant blocks C1, C2, and C3 to vectors. Then simulate and highlight coverage results on the model.

vectorDoubleIn = Simulink.SimulationInput(modelName);
vectorDoubleIn = setBlockParameter(vectorDoubleIn,modelName + "/C1","Value","[1 1]");
vectorDoubleIn = setBlockParameter(vectorDoubleIn,modelName + "/C2","Value","[0 1]");
vectorDoubleIn = setBlockParameter(vectorDoubleIn,modelName + "/C3","Value","[0 0]");
vectorDoubleOut = sim(vectorDoubleIn);
cvmodelview(vectorDoubleOut.covdata);

Click the MinMax block named Minimum and look at the relational boundary table.

There are two rows for input 1 and input 3 and four rows for input 2 because each input is a vector with two elements.

The first row is input 1(1) - min(input elements 1 after input 1). To understand this value, expand it into MATLAB® syntax:

input1(1) - min(input2(1),input3(1))

The first row of the table evaluates the difference between the first element of input 1 and the minimum of the first element of the other inputs, then checks if that difference is between the negative of the set tolerance and zero, inclusive of both.

Collect Coverage for Mixed-Size Inputs

If you have mixed-size inputs to a MinMax block, such as two scalar inputs and one vector input, Simulink implicitly expands each scalar input into a vector of the same size as the vector input. Set the Constant blocks C1 and C2 to scalar values 1 and 0, respectively, and set Constant block C3 to a column vector of zeros with two elements.

mixedSizeIn = Simulink.SimulationInput(modelName);
mixedSizeIn = setBlockParameter(mixedSizeIn,modelName + "/C1","Value","1");
mixedSizeIn = setBlockParameter(mixedSizeIn,modelName + "/C2","Value","0");
mixedSizeIn = setBlockParameter(mixedSizeIn,modelName + "/C3","Value","[0 0]");

Simulate the model and highlight the coverage results.

mixedSizeOut = sim(mixedSizeIn);
cvmodelview(mixedSizeOut.covdata);

Click on the MinMax block named Minimum and look at the relational boundary table.

The relational boundary table displays the results as if all three Constant blocks have vector inputs because of the implicit expansion that Simulink performs. In this case, Simulink expands the C1 value of 1 into the vector [1,1], and the C2 value of 0 into the vector [0,0].

If you mix data types, such as one integer input and two double inputs, the MinMax block follows the same strictness rules as other blocks. For more information, see Relational Boundary Coverage.

See Also

Related Topics