7 Calculations | 115
l
Condition for speed range: (Speed > 40) AND (Speed <= 80)
l
True case: integration of CO
2
emission gas flow
l
False case: neutral value for integration, i.e. 0
CO2_Amount = Accumulate_Prefix_Integral ( ( (Speed > 40)
AND (Speed <= 80) ) ? CO2_Emission : 0 )
Accumulate_Prefix_Integral is the name of the Integral function
starting with the first sample.
2. You want to calculate the distance driven on a test trip in a speed range of
40 to 80 km/h only.
The distance can be calculated as Integral of the Speed signal. Only the
sections within the given speed range shall be considered.
l
Condition for speed range: (Speed > 40) AND (Speed <= 80)
l
True case: current Speed value is used for integral calculation
l
False case: a neutral value for the integral calculation, i.e. 0
Distance = [Factor *] Accumulate_Prefix_Integral ( (
(Speed > 40) AND (Speed <= 80) ) ? Speed : 0 )
Assuming that the unit for the speed is km/h, and the distance shall be in
kilometers, you must apply a conversion factor = 1 / 3600.
3. You want to know for how long the speed was in the range of 40 to 80 km/h
Duration = Accumulate_Prefix_Integral ( (Speed > 40) AND
(Speed <= 80) )
As the condition itself results already in a value of 1 or 0, a pure integral
operation is sufficient, and the If-Then-Else function must not be used.
By the mentioned formula the duration is given in seconds.
If-Then-Else to ignore samples
In all the above listed examples, the If-Then-Else function allows to calculate
a result based on a specific condition. There is a calculation result for every
sample, including those which do not fulfill the condition. By the appropriate
selection of the neutral value, there is no effect for the calculation result, but still
a value for every time stamp, i.e. every input sample. This can be seen, for
example, by the curve drawn in an oscilloscope, which is a continuous line.
In some cases it is not so simple to find a neutral value for the calculation result.
Then it is helpful if you can ignore samples for the calculation. This is the case in
an average calculation where you have to ignore samples as there is not an appro-
priate neutral value.
To exclude samples completely, i.e. that there is no result of the calculation, you
can use the No Value function. Actually, the No Value function does not
delete samples, but sets a flag to the value that shall be ignored.
There are two ways of creating samples with a No Value flag.
Examples:
MDA V8 | User Guide