Arithmetic average filtering method is suitable for filtering general signals with random interference . The characteristic of this kind of signal is that the signal itself fluctuates up and down near a certain value range , Such as flow measurement , level ;
        Basic methods : Press enter N Sample data , Looking for such a Y , bring Y The sum of squares of the deviations from each sample value is the minimum .
        Attention should be paid to the arithmetic average filtering program :
                one , In order to speed up the speed of data measurement , The measured data can be stored in the memory first , The test is finished N After two o'clock , Again N The average value of each data was calculated ;
                two , Select the appropriate data format , In other words, fixed-point number or floating-point number .

The procedure is as follows :
#include <stdio.h> // Define filter data type typedef int filter_type; // Function declaration filter_type
filter(filter_type value_buf[], int num); // Arithmetic mean filter function filter_type
filter(filter_type value_buf[], int num) { int sum, i; sum = 0; for(i=0; i<num;
i++) sum += value_buf[i]; return (filter_type)(sum/num); } // Print test void main() {
filter_type ave; filter_type a[5]= {55, 44, 88, 99, 11}; ave = filter(a,
sizeof(a)/sizeof(filter_type)); printf("%d", ave); }
Output results :(55+44+88+99+11)/5 = 59.4

Technology