Software
147
4.3, a suitable filter is applied to reduce noise generated from electrical interference
and ADC inaccuracies. This is important because a small change in voltage represents
a large change in measured range, particularly at long ranges. Therefore it is
necessary to filter out noise before the voltage-to-range calculation is applied. A
number of different filtering techniques were considered including:
• Mean
• Weighted mean
• Sliding median
Mean
The mean or average of a group of samples is the most effective way of filtering small
amounts of noise. The function is easily implemented with the MATLAB function
mean and provides a fast response to change. The downside is extreme values in the
data set can significantly affect the result over the short term.
Equation 5.2
E
i
: i
th
sample
Ē: mean of samples
n: number of data samples
Weighted Mean
The weighted mean provides an extension to the standard averaging function by
allowing a different weighting factor to be applied to each data point. The sum of all
the weighting factors must equal 1 and a number of different methods can be used to
assign the weighting factors such as weights based on sample age or proximity to the
median. Although MATLAB does not have any weighted mean functions built the
algorithms can be generated very simply using basic arithmetic.
n
E
E
n
i
i
∑
=
=
1
Commentaires sur ces manuels