Академический Документы
Профессиональный Документы
Культура Документы
Introduction Various MATLAB IEEE functions help you work with difference equations and filters to shape the variations in the raw data. These functions operate on both vectors and matrices. Filter data to smooth out high-frequency fluctuations or remove periodic trends of a specific frequency.
A vector input represents a single, sampled data signal (or sequence). For a matrix input, each signal corresponds to a column in the matrix and each data sample is a row.
Back to Top
y = filter(b,a,x) creates filtered data y by processing the data in vector x with the filter described by vectors a and b.
The filter function is a general tapped delay-line filter, described by the difference equation
Here, n is the index of the current sample, is the order of the polynomial described by vector a, and is the order of the polynomial described by vector b. The output y(n) is a linear combination of current and previous inputs, x(n) x(n 1)..., and previous outputs, y(n 1) y(n 2)... .
Back to Top
Smooth the data in count.dat using a moving-average filter to see the average traffic flow over a 4-hour window (covering the current hour and the previous 3 hours). This is represented by the following difference equation:
a = 1; b = [1/4 1/4 1/4 1/4]; For information on loading the data in this example, see Loading the count.dat Data
y = filter(b,a,x); The filtered data, represented by the solid line in the plot, is the 4-hour moving average of the count data. The original data is represented by the dashed line.
Back to Top
You use the discrete filter to shape the data by applying a transfer function to the input signal.
Depending on your objectives, the transfer function you choose might alter both the amplitude and the phase of the variations in the data at different frequencies to produce either a smoother or a rougher output.
Here Y(z) is the z-transform of the filtered output y(n). The coefficients b and a are unchanged by the ztransform.
In digital signal processing (DSP), it is customary to write transfer functions as rational expressions in and to order the numerator and denominator terms in ascending powers of .
x = count(:,1); Enter the coefficients of the denominator ordered in ascending powers of to represent :
y = filter(b,a,x); Compare the original data and the shaped data with an overlaid plot of the two curves:
t = 1:length(x); plot(t,x,'-.',t,y,'-'), grid on legend('Original Data','Shaped Data',2) The plot shows this filter primarily modifies the amplitude of the original data.
http://www.mathworks.com/help/techdoc/data_analysis/bqm3i7m-1.html