7 Calculations | 117
With Distance = [Factor *] Accumulate_Prefix_Integral ( (
(Speed > 40) AND (Speed <= 80) ) ? Speed : 0 )
Note: Although the calculation
Accumulate_Prefix_Integral ( ( (Speed > 40) AND (Speed
<= 80) ) ? Speed : NoValue (0) )
would also show a curve with the same gaps as the Interrupted_
Distance_Curve signal, the result would not be as you might expect it.
This is an effect of the Integral function: If there is no sample (or a sample
with No Value flag), the integral uses the last available sample value for
the whole time range until the next sample is available.
If-Then-Else to ignore samples with Not a Number (NaN) state
In some cases your recorded signal includes already samples with Not a Num-
ber (NaN) value.
Typically such specific samples prevent a subsequent calculation, and again you
need a method to exclude such samples from your calculation.
Examples:
1. To eliminate a NaN sample, you need to detect first a NaN sample, and then
assign the No Value flag instead.
Condition for Not a Number: InputSignal != InputSignal
As NaN prevents calculation for a sample, the condition is true if the input
signal has at that point in time a NaN sample.
You can directly replace the lengthy If-Then-Else function with the
shorter SetNoValueStatus function:
InputSignal_without_NaN = SetNoValueStatus (InputSignal,
InputSignal != InputSignal)
You can use the InputSignal_without_NaN for calculations with history
(like Average, Minimum, Maximum) and still get a result in which the NaN
samples are excluded.
2. Excluding NaN samples from integral calculation
As already mentioned above, the No Value state effects an integral cal-
culated in an undesired manner.
Therefore, to exclude NaN values from an integral calculation, you must
use the If-Then-Else calculation, so that the NaN samples get the neut-
ral value for the integral calculation, namely 0.
Integral_excl_NaN = Accumulate_Prefix_Integral (
InputSignal != InputSignal ? 0 : InputSignal)
MDA V8 | User Guide