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

📄 zpole_zp.m

📁 经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助
💻 M
字号:
%===========================================================
%  Program name:zpole_zp.m 
%  This program is used to plot the zeor-pole diagram,the impulse response and 
%  the frequency response curves
%  a:The coefficient vector of the numerator polynomial of the system
%  b:The coefficient vector of the denominator polynomial of the system
%  p:The pole vector
%  q:The zero vector
%===========================================================
clear;close all;
%b=input('Type in the coefficient vector of numerator polynomial:');
%a=input('Type in the coefficient vector of denominator polynomial:');
%p=roots(a);                       %求系统极点
%q=roots(b);                       %求系统零点
q=input('Type in the zero vector:');
p=input('Type in the pole vector:');
k=input('Type in the gain K=');
[b,a]=zp2tf(q',p',k);
p=roots(a);                       %求系统极点
q=roots(b);                       %求系统零点
p=p';					          %将极点列向量转置为行向量
q=q';					          %将零点列向量转置为行向量
x=max(abs([p q]));				  %确定坐标范围
x=x+1;
y=x;						      

subplot(2,2,1);
axis([-x x -y y]);		          %确定坐标轴显示范围
axis('square')
plot([-x x],[0 0]);hold on; 	       %画横坐标轴
plot([0 0],[-y y]);hold on;		       %画纵坐标轴
plot(real(p),imag(p),'rx');hold on;     %画极点
plot(real(q),imag(q),'ro');hold on;     %画零点
grid on;
title('zero-pole diagram');
xlabel('real axis');ylabel('imaginal axis')
text(0.1*max(x),max(y),'jw')
axis([-x,x,-y,y])
%===========================================================
%  绘制冲激响应曲线
%===========================================================
subplot(2,2,3);
t=0:0.01:15;
h=impulse(b,a,t);
plot(t,h)
xlabel('time');
ylabel('Impulse response')
grid on;axis([0,15,1.1*min(h),1.1*max(h)])
%============================================================
subplot(222)
w=-5*pi:0.1:5*pi;
H=freqs(b,a,w);
plot(w,abs(H));axis([-5*pi,5*pi,0,1.1*max(abs(H))])
grid on;title('The frequency response H(jw)')
subplot(224),
plot(w,angle(H))
axis([-5*pi,5*pi,-pi,pi])
grid on;
xlabel('Frequency in radians/s')

⌨️ 快捷键说明

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