Results 1 to 15 of 15

Math Help - Simple question regarding matlab maximum passband/stopband ripple

  1. #1
    Newbie
    Joined
    Nov 2009
    Posts
    14

    Simple question regarding matlab maximum passband/stopband ripple

    Hi guys,

    I have just got a very simple question regarding maximum passband and stopband ripple in matlab.

    suppose I have the following filter frequency plots:

    Imageshack - filter2c.jpg

    Imageshack - filter1g.jpg

    What are the maximum passband/stopband ripple of each filter ? And how do you find them?

    Thanks a lot
    Last edited by CaptainBlack; May 18th 2010 at 07:26 PM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by meddi83 View Post
    Hi guys,

    I have just got a very simple question regarding maximum passband and stopband ripple in matlab.

    suppose I have the following filter frequency plots:

    Imageshack - filter2c.jpg

    Imageshack - filter1g.jpg

    What are the maximum passband/stopband ripple of each filter ? And how do you find them?



    Thanks a lot
    You will find the equivalent to the attached in any book on filter design. If the filter design tools don't provide methods of measuring them you will gave to write your own (don't recall any longer if it does have tools to directly measure these things from a filter definition)




    CB

    Attached Thumbnails Attached Thumbnails Simple question regarding matlab maximum passband/stopband ripple-gash.jpg  
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Nov 2009
    Posts
    14
    So I suppose the passband ripple for both frequencies is around 0, and the stopband around 75 ? ?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Nov 2009
    Posts
    14
    Sorry, stopband I mean around -75.. right?

    P.S. How to du measure the ripple ? in db?
    Last edited by CaptainBlack; May 18th 2010 at 07:28 PM.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by meddi83 View Post
    Sorry, stopband I mean around -75.. right?

    P.S. How to du measure the ripple ? in db?
    In both cases the stopband ripple is ~ -50dB re the passband nominal response.

    By the way I would be very sceptical about your phase plots, they would normally be restricted to the range -180 to 180 degrees.

    CB
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Nov 2009
    Posts
    14
    First of all thank you for your reply and help CB.

    So I suppose 'maximum stopband ripple' refers to the maximum value of the stopband, right? Same with passband respectively?

    So if I assume the above, the maximum passband ripple is 0 db, right?

    About the phase, I have no idea..

    But I can tell you how the filters are designed if that helps

    Basically they are fir1 filters:

    fil1 = fir1(100,[0.19 0.28]);

    fil2 = fir1(100,0.01);
    Last edited by CaptainBlack; May 18th 2010 at 07:30 PM.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Nov 2009
    Posts
    14
    Hi again,

    I was told that, given the freq response H(w) of a filter, in order to find the ripple response, I do the following subtraction:

    H(w) - D(w) where D(w) is the desirable response.

    For the maximum passband ripple we have to find the maximum absolute value in the passband and for for the maximum stopband ripple find the absolute maximum absolute value in the stopband.

    The thing is, I do have the H(w) (for example say I use H = freqz(fir1(100,0.01)) ), What is the desirable D(w) ? ?

    Regards
    Last edited by CaptainBlack; May 18th 2010 at 07:36 PM.
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by meddi83 View Post
    Hi again,

    I was told that, given the freq response H(w) of a filter, in order to find the ripple response, I do the following subtraction:

    H(w) - D(w) where D(w) is the desirable response.

    For the maximum passband ripple we have to find the maximum absolute value in the passband and for for the maximum stopband ripple find the absolute maximum absolute value in the stopband.

    The thing is, I do have the H(w) (for example say I use H = freqz(fir1(100,0.01)) ), What is the desirable D(w) ? ?

    Regards
    D(\omega) is your problem; it is the charaterisation of your design requirement. Usually it is unity in the pass band and zero in the stop band/s (and you don't care in the transition zone/s).

    CB
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Nov 2009
    Posts
    14
    Quote Originally Posted by CaptainBlack View Post
    D(\omega) is your problem; it is the charaterisation of your design requirement. Usually it is unity in the pass band and zero in the stop band/s (and you don't care in the transition zone/s).

    CB

    Thank you for your reply, CB.

    Unfortunately I have never done signals and this kind of stuff in my life before and I don't understand much from these stuff.

    The main aim of the project is to record 10 training patters for 10 classes (done this).

    Then pass them through 20 fir1 filters - using convolution - and evaluate the output of the filter at the time index 0. (The filters have length 100, transition band bandwidth is 0.002pi (Δ=0.001pi) and the first 10 are uniformly distributed between [0, pi/10] and the other 10 between [pi/10, pi]. (done this too)

    Basically I finished the matlab programming, I get the results etc, but I am asked to plot the frequency responses of all the filters (i did using freqz(filter) ) and then list the maximum passband/stopband ripples of these filters.

    Is any of the information provided useful on how to find the maximum passband/stopband ripples?

    Sorry for all my stupid questions but I am totally new to this stuff.
    Regards
    Last edited by CaptainBlack; May 18th 2010 at 07:34 PM.
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by meddi83 View Post
    Thank you for your reply, CB.

    Unfortunately I have never done signals and this kind of stuff in my life before and I don't understand much from these stuff.

    The main aim of the project is to record 10 training patters for 10 classes (done this).

    Then pass them through 20 fir1 filters - using convolution - and evaluate the output of the filter at the time index 0. (The filters have length 100, transition band bandwidth is 0.002pi (Δ=0.001pi) and the first 10 are uniformly distributed between [0, pi/10] and the other 10 between [pi/10, pi]. (done this too)

    Basically I finished the matlab programming, I get the results etc, but I am asked to plot the frequency responses of all the filters (i did using freqz(filter) ) and then list the maximum passband/stopband ripples of these filters.

    Is any of the information provided useful on how to find the maximum passband/stopband ripples?

    Sorry for all my stupid questions but I am totally new to this stuff.
    Regards
    You need to be able to calculate the frequency response of your filters are (at a set of closely spaced points which you appear to have) once you have that you can just find the maximum discrepancies in the pass and stop bands.

    Compute \max(||H(\omega)|-1|) for \omega in the pass band and \max(||H(\omega)|) for \omega in the stop band/s.

    You might have found this easier if you had used the Parks-McLelland design tool for equiripple FIR's where the ripple levels are among the design parameters.

    CB
    Follow Math Help Forum on Facebook and Google+

  11. #11
    Newbie
    Joined
    Nov 2009
    Posts
    14
    Quote Originally Posted by CaptainBlack View Post
    You need to be able to calculate the frequency response of your filters are (at a set of closely spaced points which you appear to have) once you have that you can just find the maximum discrepancies in the pass and stop bands.

    Compute \max(||H(\omega)|-1|) for \omega in the pass band and \max(||H(\omega)|) for \omega in the stop band/s.

    You might have found this easier if you had used the Parks-McLelland design tool for equiripple FIR's where the ripple levels are among the design parameters.

    CB

    CB, Thank you again for your reply.

    Suppose I have the following filter: h = fir1(100, [0.19 0.28]) - vector of size 1x101

    I use [Hw,f] = freqz(h) . This return me a vector 'Hw' of Frequency responses of length 512x1 and 'f' a vector of the corresponding frequencies of length agai 512x1.

    I suppose what you meant is, for the maximum passband ripple, find max(||Hw|-1|) and for maximum stopband ripple max(|Hw|) . How do I find out which of the 512 points of Hw belong to passband and which belong to stopband ?

    P.S. I tried using both max functions on whole Hw and they both return '1'.

    Regards
    Last edited by CaptainBlack; May 18th 2010 at 07:33 PM.
    Follow Math Help Forum on Facebook and Google+

  12. #12
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by meddi83 View Post
    CB, Thank you again for your reply.

    Suppose I have the following filter: h = fir1(100, [0.19 0.28]) - vector of size 1x101

    I use [Hw,f] = freqz(h) . This return me a vector 'Hw' of Frequency responses of length 512x1 and 'f' a vector of the corresponding frequencies of length agai 512x1.

    I suppose what you meant is, for the maximum passband ripple, find max(||Hw|-1|) and for maximum stopband ripple max(|Hw|) . How do I find out which of the 512 points of Hw belong to passband and which belong to stopband ?

    P.S. I tried using both max functions on whole Hw and they both return '1'.

    Regards
    The return value f contains the frequency scale. If the pass band is 0 to 0.19 then and the stop band 0.28 to 1:

    Code:
    idx=find((f<0.19)&&(f>0))   %gives the indices of the f array
                                %corresponding to the pass band
    
    xx=abs(abs(Hw(idx))-1)     %pass band ripple
    
    idx=find((f>0.28)&&(f<max(f)))   %gives the indices of the f array
                                     %corresponding to the stop band
    
    yy=abs(Hw(idx))                      %stop band ripple
    CB
    Follow Math Help Forum on Facebook and Google+

  13. #13
    Newbie
    Joined
    Nov 2009
    Posts
    14
    Quote Originally Posted by CaptainBlack View Post
    The return value f contains the frequency scale. If the pass band is 0 to 0.19 then and the stop band 0.28 to 1:

    Code:
    idx=find((f<0.19)&&(f>0)) %gives the indices of the f array
    %corresponding to the pass band
    
    xx=abs(abs(Hw(idx))-1) %pass band ripple
    
    idx=find((f>0.28)&&(f<max(f))) %gives the indices of the f array
    %corresponding to the stop band
    
    yy=abs(Hw(idx)) %stop band ripple
    CB

    Oh now I get it; thank you CB!

    By the way the find commands return me an error:

    ??? Operands to the || and && operators must be convertible to logical scalar values.

    (though using just one logical function works; seems like && causes an error).

    Any idea how to fix this?

    Regards,
    Last edited by CaptainBlack; May 18th 2010 at 07:32 PM.
    Follow Math Help Forum on Facebook and Google+

  14. #14
    Newbie
    Joined
    Nov 2009
    Posts
    14
    Nevermind, I used the "AND ()" function and it worked. thanks a lot CB,

    Hopefully this is what I am supposed to provide them with!

    Regards
    Follow Math Help Forum on Facebook and Google+

  15. #15
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by meddi83 View Post
    Oh now I get it; thank you CB!

    By the way the find commands return me an error:

    ??? Operands to the || and && operators must be convertible to logical scalar values.

    (though using just one logical function works; seems like && causes an error).

    Any idea how to fix this?

    Regards,
    (f>0.28).*(f<max(f))

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: March 3rd 2011, 07:42 PM
  2. Matlab. Simple???
    Posted in the Math Software Forum
    Replies: 5
    Last Post: June 28th 2010, 07:45 PM
  3. Matlab - Maximum indices matrix
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 9th 2010, 06:28 AM
  4. simple matlab question
    Posted in the Math Software Forum
    Replies: 2
    Last Post: October 15th 2009, 12:29 PM
  5. Simple Matlab problem
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 25th 2009, 12:07 AM

Search Tags


/mathhelpforum @mathhelpforum