DSPRelated.com
Forums

Magnitude frequency response

Started by Face March 7, 2006
Hi,

I need to plot the magnitude frequency response of a filter without using
the DFT method.

The input to the filter (2nd order) is a sequence of the form
cos(2pi*m*n/40) where the frequency w = 2pi*m/40. n and m vary

I need to plot the response as a function of the frequency (w).

I understand how to calculate the impulse response at each frequency, but
I don't know how to get the frequency response at each frequency for
different values of n.

How would I go about this?
Thanks

Simon


Face wrote:

> I need to plot the magnitude frequency response of a filter without using > the DFT method. > > The input to the filter (2nd order) is a sequence of the form > cos(2pi*m*n/40) where the frequency w = 2pi*m/40. n and m vary > > I need to plot the response as a function of the frequency (w). > > I understand how to calculate the impulse response at each frequency, but > I don't know how to get the frequency response at each frequency for > different values of n. > > How would I go about this?
we had another thread about this very recently. it's been all worked out (including dealing with the nasty numerical issue of what to do at the bottom octaves where cos(w) is so damn close to 1): http://groups.google.com/group/comp.dsp/browse_frm/thread/8c0fa8d396aeb444/a1bc5b63ac56b686 r b-j
"Face" <simon@digidots.co.uk> writes:

> Hi, > > I need to plot the magnitude frequency response of a filter without using > the DFT method. > > The input to the filter (2nd order) is a sequence of the form > cos(2pi*m*n/40) where the frequency w = 2pi*m/40. n and m vary > > I need to plot the response as a function of the frequency (w). > > I understand how to calculate the impulse response at each frequency, but > I don't know how to get the frequency response at each frequency for > different values of n. > > How would I go about this? > Thanks
function y = firgain(f, b) %function y = firgain(f, b) % Author: Randy Yates % Class: ECE 713 % Professor: Dr. W. Alexander % Description: Computes the linear gain at the relative frequency f, % -1 < f < 1, for the FIR filter vector in b. A frequency % of 1 corresponds to Fs/2 Hz. % force to row vector form and find length NN = size(b); if NN(1) ~= 1 b = b.'; end N = NN(2); z = exp(-j*pi*f); sum = 0; zn = 1; for n=1:N, sum = sum + b(n)*zn; zn = zn * z; end y = abs(sum); -- % Randy Yates % "Remember the good old 1980's, when %% Fuquay-Varina, NC % things were so uncomplicated?" %%% 919-577-9882 % 'Ticket To The Moon' %%%% <yates@ieee.org> % *Time*, Electric Light Orchestra http://home.earthlink.net/~yatescr
Do you want the magnitude frequency response of the filter OR the
magnitude spectrum of the output of the filter with the given input?

It makes a difference...

Fred

>Do you want the magnitude frequency response of the filter OR the >magnitude spectrum of the output of the filter with the given input? > >It makes a difference... > >Fred > >
Well i'm a little confused about this now. I will state the question in full and you can make judgement on it, Input sequence {x[n]} = cos(2*pi*m*n/40) where 0 <= n < 40 and 1 <= m <= 20. "Plot the magnitude frequency response of the filter. Note: You will need to find a suitable way to measure the response as a function of w = 2*pi*m/40 from the time response for each m. Do not use the DFT method to compute the magnitude frequency response."
Face wrote:
> >Do you want the magnitude frequency response of the filter OR the > >magnitude spectrum of the output of the filter with the given input? > > > >It makes a difference... > > > >Fred > > > > > > Well i'm a little confused about this now. I will state the question in > full and you can make judgement on it, > > Input sequence {x[n]} = cos(2*pi*m*n/40) where 0 <= n < 40 and 1 <= m <= > 20. > > "Plot the magnitude frequency response of the filter. Note: You will need > to find a suitable way to measure the response as a function of w = > 2*pi*m/40 from the time response for each m. Do not use the DFT method to > compute the magnitude frequency response."
FIR filter, IIR filter, analog filter, or some sort of nonlinear filter? What are the advantages of methods which do not involve a DFT to compute magnitude frequency response of a filter over a set of discrete frequencies? For IIR filters, one disadvantage of a DFT approach is that the impulse response has to be truncated for some finite DFT/FFT length. -- rhn A.T nicholson d.0.t C-o-M
"Face" <simon@digidots.co.uk> wrote in message 
news:99KdnQmF2I4CeZDZnZ2dnUVZ_s2dnZ2d@giganews.com...
> >Do you want the magnitude frequency response of the filter OR the >>magnitude spectrum of the output of the filter with the given input? >> >>It makes a difference... >> >>Fred >> >> > > Well i'm a little confused about this now. I will state the question in > full and you can make judgement on it, > > Input sequence {x[n]} = cos(2*pi*m*n/40) where 0 <= n < 40 and 1 <= m <= > 20. > > "Plot the magnitude frequency response of the filter. Note: You will need > to find a suitable way to measure the response as a function of w = > 2*pi*m/40 from the time response for each m. Do not use the DFT method to > compute the magnitude frequency response."
Waitaminnit... You say that you know how to compute the impulse response at *a* frequency. That makes no sense. Oh well... I would be tempted to go for an analytical solution if you know what the filter is. If the filter is a black box then you need the output resulting from the input - which you apparently don't have. So, I'm hard pressed to help with this information. Fred
> >"Face" <simon@digidots.co.uk> wrote in message >news:99KdnQmF2I4CeZDZnZ2dnUVZ_s2dnZ2d@giganews.com... >> >Do you want the magnitude frequency response of the filter OR the >>>magnitude spectrum of the output of the filter with the given input? >>> >>>It makes a difference... >>> >>>Fred >>> >>> >> >> Well i'm a little confused about this now. I will state the question
in
>> full and you can make judgement on it, >> >> Input sequence {x[n]} = cos(2*pi*m*n/40) where 0 <= n < 40 and 1 <= m
<=
>> 20. >> >> "Plot the magnitude frequency response of the filter. Note: You will
need
>> to find a suitable way to measure the response as a function of w = >> 2*pi*m/40 from the time response for each m. Do not use the DFT method
to
>> compute the magnitude frequency response." > >Waitaminnit... You say that you know how to compute the impulse response
at
>*a* frequency. That makes no sense. > >Oh well... I would be tempted to go for an analytical solution if you
know
>what the filter is. > >If the filter is a black box then you need the output resulting from the
>input - which you apparently don't have. > >So, I'm hard pressed to help with this information. > >Fred > >
So if I'm not making much sense, it doesn't make much sense to me at the moment. However the filter coefficients are know, and the output sequence can be computed from the input sequences x[n] {x[n]} = cos(2*pi*m*n/40) where 0 <= n < 40 and 1 <= m <= 20. What I don't know how do is obtain the frequency response of the filter from the input and output sequences alone.
"Face" <simon@digidots.co.uk> wrote in message 
news:p_SdnZtdta2qD5PZRVn-jw@giganews.com...
> > > > So if I'm not making much sense, it doesn't make much > sense to me at the > moment. > > However the filter coefficients are know, and the output > sequence can be > computed from the input sequences x[n] > > {x[n]} = cos(2*pi*m*n/40) where 0 <= n < 40 and 1 <= m <= > 20. > > What I don't know how do is obtain the frequency response > of the filter > from the input and output sequences alone. >
In general, you can't. That's because your driving function, x[n], only contains a finite number of frequency components (20, in fact). So the best you can do is compute the response at those frequencies. I missed the part where you said your filter is IIR or FIR, and whether it is linear. If it's linear, you can use superposition and claim that you can calculate the responses to each driving frequency individually. I may be completely out in left field, but I think you solve your problem this way: (1) If you know everything about your filter, you can write the Z-domain transfer function for it. (2) If your filter is linear then, at each of the 20 input frequencies w[m]=2*pi*m/40 in your set of x[n], you replace the Zs in the transfer function with (cos(w[m])+j*sin(w[m])). (3) You plug in the value for each w[m] to get a complex number at each of the frequencies in the driving set. The magnitude response falls out in your lap, as does the phase response, if you want it! The set of results is your frequency response over the 20 driving frequencies.
Great, that helped a lot!