How to generate Digital Filter Coefficient and test the Filter in Matlab

| |
This blog post shows how to generate a digital filter coefficient for a given input signal and then test the filter with impulse input signal.

Matlab has a two functions that are in a way inverse to each other. These function are prony and filter. The prony function generates Z transform of input signal with filter coefficient. The filter function generates output impulse response in response to given filter coefficients and input signal. Delta signal can be used with the filter coefficient to test the filter.

First generate some input signal like the following,

n = [0:50];
x = sin(2*pi*n/25);

Then use this signal x to determine filter coefficients a,b with the help of prony matlab function as follows,

[b,a] = prony(x,2,2);

The syntax of this function is,

[b,a] =prony{x,M,N)

where x is the input signal, M is the number of zeros and N is the number of poles

We can plot the input signal x as follows,

plot(n,x,*)

The plot is,


Now, we use the a,b coefficients generated above and check whether these filter coefficients generates the same output x in response to an input delta impulse.

Define delta signal to apply to the filter,

d = [1 zeros(1,50)];

Then apply this delta input to the filter using filter matlab function to get the filter response y,

y = filter(b,a,d);

Now plot y,



We see that when first x signal generated a and b coefficients and these coefficient were used for a filter we get the same signal back y for an input delta signal.

Indeed, we may plot both x and y on the same graph to see the result,

plot(n,x,*,n,y,o)

which gives,


So in this way we can use the prone and filter matlab functions to generate filter coefficients and later utilize them to build a digital filter. So these function are quite useful in Digital Signal Processing work using matlab.

Related Posts by Categories

0 comments:

Post a Comment