jc_0805: Numerical operation block inputs

Since R2020a

Guideline Publication

Control Algorithm Modeling Guidelines - Using MATLAB®, Simulink®, and Stateflow®

Sub ID Recommendations

• NA-MAAB — a1/a2, b, c1/c2, d, e, f1/f2, g, h, i, j

• JMAAB — a1/a2, b, c1/c2, d, e, f1/f2, g, h, i, j

All

Rule

Sub ID a1

When using and Abs block with signed integer types, the input shall not be the most negative value.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Sub ID a2

Abs block parameter Saturation on Integer Overflow shall be selected.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Sub ID b

Input to the Abs block shall not be unsigned integer types or fixed-point types.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Sub ID c1

Input to the Sqrt block shall not be a negative value.

Custom Parameter

Not Applicable

Example — Correct

Negative number is saturated with 0.

Simulation result

Example — Incorrect

Sub ID c2

Sqrt block parameter Output Signal Type shall be set to `complex`.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Sub ID d

Input to the Reciprocal Sqrt block shall not be less than zero.

Custom Parameter

Not Applicable

Example — Correct

Less than eps saturated with eps.

Simulation result: Plot as Y=log10(Z)

Example — Incorrect

Sub ID e

When Math Function block parameter Function is set to `log` or `log10`, the input to the block shall not be zero.

Custom Parameter

Not Applicable

Example — Correct

Replace within ±eps with ±eps

Simulation result: Plot as Y = |Z|

Example — Incorrect

Sub ID f1

When Math Function block parameter Function is set to `log` or `log10`, the input to the block shall not be a negative number.

Custom Parameter

Not Applicable

Example — Correct

When the input is less than eps, the value is saturated to eps. Less than eps saturated with eps.

Simulation result

Example — Incorrect

Sub ID f2

When Math Function block parameter Function is set to `log` or `log10`, block parameter Output Signal Type shall be set to `complex`.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Sub ID g

When Math Function block parameter Function is set to `mod` or `rem`, the second argument input shall not be zero.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Sub ID h

When Math Function block parameter Function is set to `reciprocal`, the input to the block shall not be zero.

Custom Parameter

Not Applicable

Example — Correct

Replace within ±eps with ±eps

Simulation result: Simulation results is not inf, but since it is close to zero, the change in the output value is significant.

Example — Incorrect

Sub ID i

When Product block parameter Multiplication is set to `Element-wise(.*)`, the divisor input shall not be zero.

Note

To specify a divisor input, set Product block parameter Number of inputs to `*/`.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Sub ID j

When Product block parameter Multiplication is set to `Matrix(*)`, the divisor input shall not be set to a singular matrix.

Note

To specify a divisor input, set Product block parameter Number of inputs to `*/`.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Rationale

Sub IDs a1, c1, d, e, f1, g, h, i, j:

• The result of entering an invalid value is implementation dependent. Deviation from the rules can result in unintended behavior.

Sub ID a2:

• Correct settings prevent unintended behavior that can result from using invalid values.

Sub ID b:

• The block can become optimized out of the generated code, resulting in a block that you cannot trace to the generated code.

Sub IDs c2, f2:

• Correct settings prevent unintended behavior that can result from using negative values.

Verification

Adherence to this modeling guideline cannot be verified by using a Model Advisor check.

R2020a