iir2 • % filter spec • wp=1000; • ws=1500; • rp=3; • rs=20; • • %Folding Frequency or Normalized Sampling frequency • fF=fs/2; • • %Normalized Analog Butterworth filter frequencies • wpa=wp/fF; • wsa=ws/fF; • [n,wc]=buttord(wpa,wsa,rp,rs); • [b,a]=butter(n,wc,"high"); • %[z,p,k]=cheb1ap(10,3); • %[zd,pd,kd] = bilinear(z,p,k,fs); • [H,f]=freqz(b,a,512,fs); • subplot(3,1,2); • plot(f,abs(H)); • figure, plot(f,angle(H)) • %plot(f,20*log10(abs(H))); • xlabel('frequency in hz'); • ylabel('magnitude'); • title(['butterworth filter of order',num2str(n)]); • %fs=input('enter the sampling frequency which is greater than twice the max'); • fs=8000; • N=1024; • %M=2; • n=0:N-1; • f1=500; • f2=2000; • • • • • • • • • • x=3*sin(2*pi*f1*n/fs)+cos(2*pi*f2*n/fs); %Spectrum of Input X=2*abs(fft(x,N))/N; %X(1)=X(1)/2; f=(0:1:N/2-1)*fs/N; subplot(3,1,1); plot(f,X(1:N/2)); xlabel('frequency in hz'); ylabel('magnitude of x'); title(['spectrum of input signal at ', num2str(f1), 'and at ', num2str(f2)]); • % grid minor • y=filter(b,a,x); % Filter the input signal • y=2*abs(fft(y,N))/N; • % %y(1)=y(1)/2; • f=(0:N/2-1)*fs/N; • subplot(3,1,3); • plot(f,y(1:N/2)); • xlabel('frequency in hz'); • ylabel('magnitude of y');