Hi everyone. Here is my project and I need your help to solve this project. I did something but I dont know what is wrong in my code. If you fix it I will get 20 points from my lecture. The most important problem is option "d" please I have to submit this project next week...
An IIR highpass filter with a Butterworth characteristic is required to satisfy the
following specifications:
Passband=2-4kHz
Stopband=0-500Hz
Passband ripple=3dB
Stopband attenuation=20dB
Sampling frequency=8kHz
Determine,
a) Pass- and stopband edge frequencies for suitable analog prototype lowpass
filter; {Hint: You should write an m-file}
b) Order, M, of the prototype lowpass filter. c) Coefficients, and hence the transfer function, of the discrete-time filter using
the impulse invariant and bilinear z-transform methods.
d) Test your filter design by applying a sinusoidal input x
with the following
frequencies:
i) 3kHz
ii) 50Hz
In this part, you are required to modify the MATLAB m-file you have written
for part (a) such that it displays the output signal y
. That is, for each input
signal, your program should plot the corresponding output signal y
. Finally,
compare the outputs obtained from the impulse invariant and bilinear z-transform
methods.
Here is my code:
fs=8000;
Ts = 1/fs; %sampling time interval
t = 0:Ts:1-Ts; %sampling period
f=input('Enter the Frequency = ');
x=sin(2*pi*f*t);
subplot(2,1,1);
plot(t,x);
title('Input x(t) ');
grid
Ap=3;
As=20;
wp=2000/4000;
ws=500/4000;
[M,wc]= buttord(wp,ws,Ap,As);
[z,p,k]= butter(M,2000/4000,'high');
[b,a]= butter(M,2000/4000,'high');
[h,t] = impz(b,a,60);
y= conv(x,h);
subplot(2,1,2);
plot