Discussion in 'Homework Help' started by red flower, Dec 10, 2010.

1. ### red flower Thread Starter New Member

Dec 10, 2010
3
0
please i need help in this matlab homework

A digital filter is described by the difference equation
y[n]=-0.9y[n-1]+0.18y[n-2]+x[n]+x[n-1]

a. Plot the magnitude and phase of the frequency response of this filter. Compare the results with the freqz command of MATLAB.
b. Generate 200 samples of the signal x [n]= sin(pi*n/ 3) 5cos(pi*n) and process through the filter. Compare the steady state response portion of the output to . How are the amplitudes and phases of the two sinusoids affected by the filter?
I solve it ,but i don't know how to get magnitude and phase..
My code is
n = -10:100;
a = [1 0.9 -0.18]; % left hand side of difference equation
b = [1 1 0]; % right hand side of difference equation
h=filter(b,a,n); %find h from difference equation
plot(n,h)
h=filter(b,a,n)
n = -10:100;
a = [1 0.9 -0.18]; % left hand side of difference equation
b = [1 1 0]; % right hand side of difference equation
h=filter(b,a,n); %find h from difference equation
plot(n,h)
h=freqz(b,a,n)

2. ### shteii01 AAC Fanatic!

Feb 19, 2010
4,436
703
magnitude=abs(frequency response)

phase=angle(frequency response)

3. ### red flower Thread Starter New Member

Dec 10, 2010
3
0
The answer not enough to understant.I don't know what I have to write in the code.I dont know why nobody help me.I really need a help.

4. ### Georacer Moderator

Nov 25, 2009
5,175
1,284
The policy of this forum is that first you, the Original Poster, must post your efforts and thoughts about tackling this problem, even if they are false, and then the community will give it a shot.

There are no freebies, even here.

5. ### Wendy Moderator

Mar 24, 2008
21,413
2,946
Give it a shot, then the people who understand the problem can point out the errors. It takes a while, but you come away understanding how to do it.

6. ### red flower Thread Starter New Member

Dec 10, 2010
3
0
Thank you very much bro....
I think that I did my effort and I post my own solution ,but I have one graph and I need two graph for mag and phase and that is my question..
This is my effort and my code
My code is
n = -10:100;
a = [1 0.9 -0.18]; % left hand side of difference equation
b = [1 1 0]; % right hand side of difference equation
h=filter(b,a,n); %find h from difference equation
plot(n,h)
h=filter(b,a,n)
n = -10:100;
a = [1 0.9 -0.18]; % left hand side of difference equation
b = [1 1 0]; % right hand side of difference equation
h=filter(b,a,n); %find h from difference equation
plot(n,h)
h=freqz(b,a,n)
This is my first time to ask for help because I always do my duties and I will never ask for help again.I prefer to submit my code even it was wrong.
Best Regards & thank you for your help