Thread: Simple question regarding matlab maximum passband/stopband ripple

1. 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

2. Originally Posted by meddi83
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

3. So I suppose the passband ripple for both frequencies is around 0, and the stopband around 75 ? ?

4. Sorry, stopband I mean around -75.. right?

P.S. How to du measure the ripple ? in db?

5. Originally Posted by meddi83
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

6. 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);

7. 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

8. Originally Posted by meddi83
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
$\displaystyle 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

9. Originally Posted by CaptainBlack
$\displaystyle 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

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

10. Originally Posted by meddi83

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 $\displaystyle \max(||H(\omega)|-1|)$ for $\displaystyle \omega$ in the pass band and $\displaystyle \max(||H(\omega)|)$ for $\displaystyle \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

11. Originally Posted by CaptainBlack
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 $\displaystyle \max(||H(\omega)|-1|)$ for $\displaystyle \omega$ in the pass band and $\displaystyle \max(||H(\omega)|)$ for $\displaystyle \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

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

12. Originally Posted by meddi83

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

13. Originally Posted by CaptainBlack
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,

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

15. Originally Posted by meddi83
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