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

📄 fig4_22.m

📁 数字信号处理Matlab演示文件,其中各个文件加放置了不同的matlab子文件
💻 M
字号:
%	Figure 4.22
%	BM
%	August 98


clear
clf
colordef(1,'black')

subplot(121)
zplane(0,0)
v = axis;
hold on
lz = line('Xdata',0,'Ydata',0,'EraseMode','xor','LineStyle','o','Color','y');
rmin = v(1);
rmax = v(2);
imin = v(3);
imax = v(4);


subplot(122)
Tmax = 20;
Osamp = 4;
dt = 1/Osamp;
T = 0:1:Tmax;
TT = 0:dt:Tmax;
axis( [0 Tmax -2 +2] )
title('impulse response')
xlabel('sample no')
ylabel('h(n)')
hold on

fprintf(1,'Figure 4.22: Impulse response & pole postion.\n');
fprintf(1,'           : Left mouse button places pole in z-plane at crosshair.\n');
fprintf(1,'           : Right mouse button for final placement.\n');


subplot(121)
[x,y] = ginput(1);
if x > rmax, x = rmax, end;
if x < rmin, x = rmin, end;
if y > imax, y = imax, end;
if y < imin, y = imin, end;
l1 = line('Xdata',x,'Ydata',y,'Marker','x','Color','y','EraseMode','xor');
l2 = line('Xdata',x,'Ydata',-y,'Marker','x','Color','y','EraseMode','xor');


subplot(122)
zp = x+j*y;
rr = abs(zp);
theta = angle(zp);
den = poly([zp conj(zp)]);
num = [ 1 -rr*cos(theta) 0 ];
[YY,XX] = dimpulse(num,den,Tmax+1);
env = rr .^ T;
ana = (rr .^ TT) .* cos( theta * TT );
lo = line('Xdata',T,'Ydata',YY(:,1),'LineStyle','o','Color','y','Erasemode','Xor');
ll = zeros(1,Tmax+1);
for ii = 1:Tmax+1
	ll(ii) = line('Xdata',[ii-1 ii-1],'Ydata',[0 YY(ii,1)],'Linestyle','-','Color','y','Erasemode','Xor'); 
end

%l3 = line('Xdata',T,'Ydata',YY(:,1),'LineStyle','-','Color','y','EraseMode','xor');
l4 = line('Xdata',T,'Ydata',env,'LineStyle',':','Color','b','EraseMode','xor');
l5 = line('Xdata',T,'Ydata',-env,'LineStyle',':','Color','b','EraseMode','xor');
l6 = line('Xdata',TT,'Ydata',ana,'LineStyle','-','Color','r','EraseMode','xor');

but = 1;
while but == 1
	subplot(121)
	[x,y,but] = ginput(1);
	if x > rmax, x = rmax; end;
	if x < rmin, x = rmin; end;
	if y > imax, y = imax; end;
	if y < imin, y = imin; end;
	set(l1,'Xdata',x,'Ydata',y);
	set(l2,'Xdata',x,'Ydata',-y);

	subplot(122)
	zp = x+j*y;
	rr = abs(zp);
	theta = angle(zp);
	den = poly([zp conj(zp)]);
	num = [ 1 -rr*cos(theta) 0 ];
	[YY,XX] = dimpulse(num,den,Tmax+1);
	env = rr .^ T;
	ana = (rr .^ TT) .* cos( theta * TT );	
	set(lo,'Xdata',T,'Ydata',YY(:,1));
	for jj=1:Tmax+1
		set(ll(jj),'Xdata',[jj-1 jj-1],'Ydata',[0 YY(jj,1)]);
	end
	set(l4,'Xdata',T,'Ydata',env);
	set(l5,'Xdata',T,'Ydata',-env);
	set(l6,'Xdata',TT,'Ydata',ana);
end

⌨️ 快捷键说明

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