⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fig4_24.m

📁 数字信号处理Matlab演示文件,其中各个文件加放置了不同的matlab子文件
💻 M
字号:
%	Pole & zeros & frequency response
%	of a digital filter
%	- animation
%	Figure 4.24
%
%	BM
%	Dec 97


clear
clf
colordef(1,'black')

%	poles & zeros
Rp = 0.7;
thetap = 45;
thetap = thetap/180*pi;
pp = Rp*[ exp(j*thetap) exp(-j*thetap) ];
zz = [0 ];
[b,a] = zp2tf(zz',pp',1);

subplot(1,2,1);
zplane(b,a);
hold on

fprintf(1,'Figure 4.24: pole/zero plot - press return to continue\n')
pause

th = 0;
pt = exp( j*th/180*pi );
xx = real(pt);
yy = imag(pt);
l1 = line('Xdata',xx,'Ydata',yy);
set(l1,'Color','w','Marker','o','EraseMode','xor');
l2 = line('Xdata', real ([ pt pp(1)] ),'Ydata',imag([ pt pp(1)]),'Color','g','LineStyle','-','EraseMode','xor'); 
l3 = line('Xdata', real ([ pt pp(2)] ),'Ydata',imag([ pt pp(2)]),'Color','g','LineStyle','-','EraseMode','xor'); 
l4 = line('Xdata', real ([ pt zz(1)] ),'Ydata',imag([ pt zz(1)]),'Color','b','LineStyle','-','EraseMode','xor'); 
l6 = line('Xdata', real ([ 0 pt ] ),'Ydata',imag([0 pt ]),'Color','r','LineStyle','-','EraseMode','xor'); 

M = 128;
[hh,w] = freqz(b,a,2*M,'whole');
%h = 10*log10(abs(hh));
h = abs(hh);
ang = unwrap(angle(hh))/pi*180;
angmax = max(ang);
angmin = min(ang);
maxh = max(h);
if min(h) < 0
	minh = min(h);
	else
	minh = 0;
	end
w = w/pi/2;

subplot(2,2,2)
xx = [ w(1) w(1) ];
yy = [ h(1) h(1) ];
ll1 = line ('Xdata',xx,'Ydata',yy,'Color','y','LineStyle','-','Erasemode','none');
ll2 = line ('Xdata',w(1),'Ydata',h(1),'Color','w','Marker','o','Erasemode','xor');
axis ([ 0 0.5 minh maxh ]);
grid
ylabel ('gain')
xlabel ('frequency')
hold on

subplot(2,2,4)
xx = [ w(1) w(1) ];
yy = [ ang(1) ang(1) ];
lx1 = line ('Xdata',xx,'Ydata',yy,'Color','y','LineStyle','-','Erasemode','none');
lx2 = line ('Xdata',w(1),'Ydata',h(1),'Color','w','Marker','o','Erasemode','xor');
axis ([ 0 0.5 angmin angmax ]);
grid
ylabel ('phase (degrees)')
xlabel ('frequency')
hold on

fprintf(1,'Figure 4.24:construction lines - press return to animate\n')
pause

step = 360/M;

for ii = 1:4:M+1;

th = (ii-1)*step/2;
pt = exp( j*th/180*pi );
set(l1,'Xdata',real(pt),'Ydata',imag(pt));
set(l2,'Xdata', real ([ pt pp(1)] ),'Ydata',imag([ pt pp(1)])); 
set(l3,'Xdata', real ([ pt pp(2)] ),'Ydata',imag([ pt pp(2)])); 
set(l4,'Xdata', real ([ pt zz(1)] ),'Ydata',imag([ pt zz(1)])); 
set(l6,'Xdata', real ([0 pt ] ),'Ydata',imag([0 pt ])); 

if ii==1,
	xx = [ w(1) w(1) ];
	yy = [ h(1) h(1) ];
else
	xx = w(ii-1:ii);
	yy = h(ii-1:ii);
end
set(ll1,'Xdata',w(1:ii),'Ydata',h(1:ii));
set(ll2,'Xdata',w(ii),'Ydata',h(ii));

if ii==1,
	xx = [ w(1) w(1) ];
	yy = [ ang(1) ang(1) ];
else
	xx = w(ii-1:ii);
	yy = ang(ii-1:ii);
end
set(lx1,'Xdata',w(1:ii),'Ydata',ang(1:ii));
set(lx2,'Xdata',w(ii),'Ydata',ang(ii));

pause(1)

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -