7 Calculations | 114
First, the use of the If-Then-Else function is a powerful way to define the true
and the false case behavior.
Second, the If-Then-Else function also allows to exclude specific samples, so
that these are skipped in the calculation.
"If-Then-Else basics" below
"If-Then-Else within another calculation" below
"If-Then-Else to ignore samples" on the next page
"If-Then-Else to ignore samples with Not a Number (NaN) state" on
page117
If-Then-Else basics
The If-Then-Else function requires a condition which results in True and
False.
Then and Else represent the two behaviors namely for the True case (Then)
and the False case (Else).
Result = Condition ? True Case : False Case
The three parts (Condition, True case, False case) in the If-Then-Else
structure are expressions which can use the same input signals or different
ones. The True case and False case can be complex formulas, single input
signals, or constants.
Example:
You want to calculate the power of the engine, but only in case the car is driving
uphill.
Uphill condition = Gradient (Altitude) > 0
True case = EngineSpeed * Load
False case = 0
Power_Uphill = Gradient (Altitude) > 0 ? EngineSpeed * Load
[* Factor] : 0
(Depending on the expected unit for Power and the units given for
EngineSpeed and Load, an additional factor for unit conversion must be
included.)
If-Then-Else within another calculation
If the If-Then-Else function is embedded in a more complex calculation, typ-
ically either the True case or the False case should be a neutral value for the
overall calculation. The most simple neutral value is 0 for an addition or sub-
traction, while it is 1 for a multiplication or division.
Examples:
1. You want to know the total amount of CO
2
emissions for the speed range
of 40 to 80 km/h. By integrating the CO
2
emission gas flow (in g/s), you can
calculate the amount.
MDA V8 | User Guide