Pole Zero
Pole Zero
'); N=input('enter the length of the dft: '); L=input('enter the truncation length: '); n=0:1:L-1; k=0:1:N-1; xn=cos(2*pi*f*n/fs)+ cos(2*pi*2*f*n/fs)+ cos(2*pi*4*f*n/fs); xk=dftb4(xn,N); figure; subplot(3,1,1); stem(k,abs(xk)); title('magnitude of dft'); subplot(3,1,2); stem(n,xn); title('input sampled signal'); xnr=idftb4(xk); subplot(3,1,3); stem(k,xnr); title('recovered signal');
%computation of DFT function[Xk]=dftb4(Xn,N) m=length(Xn); if m<N Xn1=horzcat(Xn,zeros(1,N-m)); else if m>=N Xn1=Xn(1:N); end end n=0:1:N-1; k=0:1:N-1; nk=n'*k; wn=exp(-j*2*pi/N); wnk=wn.^nk; Xk=Xn1*wnk; end
% computation of IDFT function[Xn]=idftb4(Xk) N=length(Xk); n=0:1:N-1; k=0:1:N-1; nk=n'*k; wn=exp(-j*2*pi/N); wnnk=wn.^(-nk); Xn=Xk*wnnk/N; end
N>L
N<L
clc; clear all; close all; p=input('Enter the location of pole less than 1'); z=input('Enter the location of zero'); w=(-100:1:100)*pi/100; subplot(3,1,1); zplane(z',p'); title(['pole-zero for','poles= ',num2str(p),'zero= ',num2str(z)]); [a b]=zp2tf(z',p',1); x=1; for i=1:length(p) if abs(p(1,i))>1 disp('system unstable'); i=i+1; x=x+1; end end if x==1 q=length(a); temp1=a(1,q)*ones(1,length(w)); if(q>1) for i=1:q-1 temp1=temp1+a(1,q-i)*exp(j*i*w); end end r=length(b); temp2=b(1,r)*ones(1,length(w)); if(r>1) for i=1:r-1 temp2=temp2+b(1,r-i)*exp(j*i*w); end end hw=temp1./temp2; maghw=abs(hw); anglehw=angle(hw); subplot(3,1,2); plot(w/pi,maghw); grid; title('magnitude plot'); subplot(3,1,3); plot(w/pi,anglehw); grid; title('phase plot'); end
All Pass:
Band Pass:
Band Stop:
Comb filter:
High Pass
Low Pass:
Max phase:
Min phase:
Mixed phase:
Notch filter:
Resonator: