Page 136 - MATLAB Recipes for Earth Sciences
P. 136

130                                                 6 Signal Processing


                Input signal x(t)
                                      bi        T
                                                                  Output signal y(t)

                              +                          +


                                         T          ai



            Fig. 6.2 Schematic of a  linear time-invariant fi lter with an input x(t) and an output y(t). The

            filter is characterized by its weights a  and b , and the delay elements T. Nonrecursive fi lters
                                       i    i
            only have nonrecursive weights b , whereas the recursive filter also requires the recursive

                                     i
            fi lters weights a .
                        i






            with the known problems in the design of zero-phase filters. The larger of
            the two quantities M and N +N or N, respectively, is the order of the fi lter.
                                    1  2
               We use the same synthetic input signal as in the previous example to il-
            lustrate the performance of a recursive fi lter.

               clear
               t = (1:100)';
               randn('seed',0);
               x5 = randn(100,1);
            We filter this input using a recursive filter with a set of weights a5 and b5,


               b5 = [0.0048    0.0193    0.0289    0.0193    0.0048];
               a5 = [1.0000   -2.3695    2.3140   -1.0547    0.1874];
               m5 = length(b5);

               y5 = filter(b5,a5,x5);
            and correct the output for the phase

               y5= y5(1+(m5-1)/2:end-(m5-1)/2,1);
               y5(end+1:end+m5-1,1)=zeros(m5-1,1);

            Now we plot the results.
               plot(t,x5,'b-',t,y5,'r-')
   131   132   133   134   135   136   137   138   139   140   141