?? zpole_zp.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 + -