# DSP Resonance filter

Discussion in 'Homework Help' started by O'Fithcheallaigh, Jan 11, 2012.

1. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Hello.

I am hoping someone can give me some advice with where to start answering the folloing question.

The transfer function for a resonance filter is

$H(z) = \frac{(1-r)(1-rz^2)}{1 - 2r cos(\omega_{c}T)z^-1 + r^2 z^-2}$

How do I Show that, for any given resonance frequency !c and any value of the parameter r, the amplitude response of the filter equals unity at $\omega = \omega_{c} = 2\pi f_{c}$, i.e. $|H(\omega_{c}| = 1$.

Seán

2. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
Make the substitution

$z=e^{j\omega_cT$

and covert the cos(ωcT) term to its complex exponential form

After some algebraic manipulation it then comes out nicely.

3. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Hello.

Can I ask, to answer this, what am I looking to manipulate the for? I mean, what will be the output?

Thanks again.

Seán

4. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
You want to show that for the stated conditions

|H(ω)|=1

Just as the Laplace continuous frequency domain variable 's' corresponds to s=jω so the sampled data frequency domain variable 'z' corresponds to z=exp(jωT). T being the sampling interval.

You are given

$H(z)=\frac{(1-r)(1-rz^2)}{1-2rcos(\omega_cT)z^{-1}+r^2z^{-2}}$

For ω=ωc make the substitutions

$z=e^{j\omega_cT}$

$z^{2}=e^{2j\omega_cT}$

$z^{-1}=e^{-j\omega_cT}$

$z^{-2}=e^{-2j\omega_cT}$

and from Euler

$cos(\omega_cT)=\frac{(e^{j\omega_cT}+e^{-j\omega_cT})}{2}$

After making the substitutions you then simplify the relationship to evaluate H(ωc) & |H(ωc)| - which hopefully turns out to be simply |H(ωc)|=1. I've yet to verify that's the case.

Remember also that one would probably assume

$\omega_cT=2\pi$

Edit:

Actually it should rather be

$\omega_c=\frac{1}{2T}$

Last edited: Jan 13, 2012
5. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
In fact - contrary to my previous post - no final assumption is required.

The algebraic reduction of H(z) [at ω=ωc] leads to the relationship

$H(\omega_c)=\frac{(1-re^{j2\omega_cT})}{(1-re^{-j2\omega_cT})}$

While this is a complex relationship (in the strict mathematical sense), a little thought will hopefully convince you that |H(ωc)|=1 for all values of r , ωc & T.

6. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Hello.

Sorry for the late reply. Family things got in the way. I have been doing as you suggested, but I think (well, no, I am sure) I have done something wrong. Probably a number of things.

Here is what I have done so far.

So,

$H(z) = \frac{(1-r)(1-re^{2j\omega_c T})}{1-2r((e^{j\omega_c T} +e^{-j\omega_c T})/2)e^{-j\omega_c T}+r^{2}e^{-2j\omega_c T}}$

Dividing should remove the 2's on the bottom line. So,

$H(z) = \frac{(1-r)(1-re^{2j\omega_c T})}{1-r(e^{j\omega_c T} +e^{-j\omega_c T})e^{-j\omega_c T}+r^{2}e^{-2j\omega_c T}}$

Removing what is inside the brackets on the bottom line ...I think I am right in doing this part. Maybe not though.

$H(z) = \frac{(1-r)(1-re^{2j\omega_c T})}{1-r (e^{-j\omega_c T})+r^{2}e^{-2j\omega_c T}}$

Taking away the (1-r) on the top and bottom

$H(z) = \frac{(1-re^{2j\omega_c T})}{e^{-j\omega_c T}+r^{2}e^{-2j\omega_c T}}$

I have maybe made a number of mistakes a long the way, so any advice would be great. Also, I may have made a few typos ...not used to the whole Tex thing.

Seán

7. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
The denominator expansion is incorrect ....

$1-2r(\frac{e^{j\omega_cT}+e^{-j\omega_cT}}{2})e^{-j\omega_cT}+r^2e^{-j2\omega_cT}=1-r-re^{-j2\omega_cT}+r^2e^{-j2\omega_cT}=1-r-r(1-r)e^{-j2\omega_cT}=(1-r)[1-re^{-j2\omega_cT}]$

8. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Hello.

Thanks again.

But can I ask, how did you get the 1 - r - re... part?

I mean, I assume you still divide to get rid of the 2's? Then, after I had written my reply, I started p;ayinga round with it some more, and if I get rid of the 2's, then multiply out the bracket by r, I get

$1 - re^{j\omega_c T} + re^{-j\omega_c T} \times re^{-j\omega_c T} + r^{2} e^{-j2\omega_c T}$

$1 - re^{j\omega_c T} + re^{-j2\omega_c T} + r^{2} e^{-j2\omega_c T}$

But I am not really sure if the multiplication of the two exponential terms is correct

But I don't really see where the

$1 - r - re^{...}...$

comes from. It is probably something simple I am missing. I sometimes think thinks are harder then they need to be.

Seán

9. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
Focus on

$e^{-j\omeg_cT}e^{j\omega_cT}=e^0=1$

and

$e^{-j\omeg_cT}e^{-j\omega_cT}=e^{-2j\omega_cT}$

which are relevant to the expansion of the denominator portion

$-2r(\frac{e^{j\omega_cT}+e^{-j\omega_cT}}{2})e^{-j\omega_cT}=-r -re^{-j2\omega_cT}$

Last edited: Jan 17, 2012
O'Fithcheallaigh likes this.
10. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Hello.

Many many thanks. I got there! I will go ver it a few more time to make sure that I have it right in my head.

And, if I have it right, any valur of r , ωc or T, will reduce down to |H(ωc)| = 1. The values of r , ωc or T will cancel out in the equation to gives 1.

I think thats right!

Anyway, again, thanks.

Seán

11. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Would this be a system difficult to implement in Matlab?

I assume it would be the final version of the equation I would need to enter?

Seán

12. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
Depends on what you actually want to do in Matlab. Do you just want to evaluate the value of H(z) at ωc or are you interested in a range of values for the variable ω?

To actually implement you would have to choose some (arbitrary but consistent) values of r, ω, ωc & T.

Last edited: Jan 17, 2012
13. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Well, I have a sampling freq of 10kHz, and I have 6 parameters for fc and r. I need to plot the amplitude response of the filter for all 6, using a linear amplitude scale.

Seán

14. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
Then you would need to use the general relationship

$H(\omega)=\frac{(1-r)(1-re^{-j2\omega T})}{1-2r\cos{(\omega_c T)}e^{-j\omega T}+r^2e^{-j2\omega T}}$

plugging in the values for each solution. Rather than solving for individual values of ω in every case, one would input the frequency ω as a linear vector spanning the range of frequencies of interest. H(ω) would be output as a corresponding vector of the same dimension as the ω input vector.

This H(ω) array will be a complex value so you would have to plot the absolute value of H(ω) [abs(H(ω))] vs ω to see the amplitude response. If you need the phase as well you would also plot arg(H(ω)) vs ω.

15. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Okay, thanks!

So, just to make sure I am right, I will need to input that whole equation in matlab?

I will need to look into the linear amplitude scale. I have never used it. Do you know of any good matlab resources?

Seán

16. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
Yes you have to input the whole function H(ω) if you want to see what happens as the input frequency ω varies. You should also see the envisaged result that |H(ωc)| is always '1'.

If you apply the input frequency as a linearly spaced vector [array] then the output will likewise be a linearly spaced array with respect to the input frequency array. You simply then do a linear scaled 2D plot of |H(ω)| [array] vs ω [array] for the amplitude response.

I don't use Matlab. I use Scilab. The Mathworks site covers most topics & functions quite comprehensively.

Sep 15, 2010
20
0
Cool. Thanks

Seán

18. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Hello.

Here is what I have at the minute, but something is not working. I fixed the errors that came up, but still no joy.

Also, I just tried this for on set of parmeters, to see if I could get it working.

I think the plot function isn't right. The window is opening, but it is not displaying anything.

Code ( (Unknown Language)):
1.
2. %% Constants %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3. fs = 10000;
4. fc = 1000;
5. wc = 2*pi*fc;
6. r = 0.99;
7.
8. %% Equation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9.  a = (1 - r)*(1 - r * exp(-1i*2*wc*T));
10.  b = 1 - 2 * r * cos(wc*T) * exp (-1i*wc*T) + r^2 * exp(-1i*2*wc*T);
11.  Hz = a/b;
12.
13.  %% Plot %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14.  figure(1);
15.  clf;
16.  plot(Hz)
17.

19. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
It sometimes helps to step back and take time to reflect on what you are attempting to do rather than coming back with another question.

Firstly, you didn't implement the function I proposed in post #14. I suggested you need a variable vector ω. Your function contains only the parameter ωc which is fixed while ω varies.

Secondly, you will have only one solution value for Hz so plotting a single point won't show much on a graph.

20. ### O'Fithcheallaigh Thread Starter Member

Sep 15, 2010
20
0
Yes. I do tend to jump right in.

I read over post #14 again.

But how can ωc be fixed when it equals 2*pi*fc, and I am given a range of values for fc (the first 3 are 1000Hz, the last 3 are 4000Hz)?

I am sorry of this is a stupid question, but it is obviously the block I am having to implement this correctly.

Oh, and I just realised, T is undefined.

Seán