I have been working on this HW and I am not sure if I did something wrong. Here
ID: 2291427 • Letter: I
Question
I have been working on this HW and I am not sure if I did something wrong. Here is my code.
%y[n]=x[n]+x[n-1]-x[n-4]-x[n-5];
%y[n]=y[n-1]-.9*y[n-2]+x[n]+x[n-1]
clear
clc
[x,fs] = audioread('toto.wav');
x = x(:,1);
dt = 1/fs;
t = 0:dt:(length(x)*dt)-dt;
plot(t,x); xlabel('Seconds'); ylabel('Amplitude');
num=[1 1 -.9];
den=[1 1 0 0 -1 -1];
sys=tf(num,den);
k=filter(num,den,x);
subplot(3,1,1);
plot(t,k);
title('filter response');
w=0:0.001:pi;
[h,om]=freqz(num,den,w)
m=20*log10 (abs(h))
an=angle(h)
subplot(3,1,2)
plot(om/pi,m)
title('mag spectrum of filter')
xlabel('freq')
ylabel('mag in db')
subplot(3,1,3)
plot(om/pi,an)
title('phase spectrum of filter')
xlabel('freq')
So I was playing around and when I use the 2nd equation at the top like in this code my filter response or the magnitude don't change. Why is that? Did I do something wrong? It doesn't even change if I change the values of the den either.
1180-1- 0-14.8 nag spectrum of titer anonoleth per. phase spectrum of nher freqExplanation / Answer
Hello user,
Your num and den vectors are wrong
for first system
num=[1 1 0 0 -1 -1];
den=[1]
for second system
num=[1 1];
den=[1 -1 9];
Please let me know if you have any doubts
Thank You.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.