?? dfre_digital.m
字號:
% Name: dfre.m
% The program to draw the frequency response of discrete system
A=input('Type in the coefficient vector of denominator polynomial:');
B=input('Type in the coefficient vector of numerator polynomial:');
k=512;r=1;
p=roots(A); %求極點
q=roots(B); %求零點
%===================================================================
p=p'; %將極點列向量轉置為行向量
q=q'; %將零點列向量轉置為行向量
x=max(abs([p q 1])); %確定縱坐標范圍
x=x+0.1;
y=x; %確定橫坐標范圍
clf
subplot(2,2,1)
hold on
axis([-x x -y y]) %確定坐標軸顯示范圍
w=0:pi/300:2*pi;
t=exp(i*w);
plot(t) %畫單位園
axis('square')
plot([-x x],[0 0]) %畫橫坐標軸
plot([0 0],[-y y]) %畫縱坐標軸
text(0.1,x,'jIm[z]')
text(y,1/10,'Re[z]')
plot(real(p),imag(p),'x') %畫極點
plot(real(q),imag(q),'o') %畫零點
title('The pole-zero diagram for discrete system') %標注標題
hold off
%===================================================================
[H,w]=freqz(B,A);
fai=angle(H);
subplot(2,2,2)
plot(w,abs(H)); %繪制幅頻特性曲線
%axis([0,0.5,0,2])
title('The amplitude reponse curve')
xlabel('Angle frequency')
ylabel('Amplitude')
subplot(2,2,4)
plot(w,fai);
%axis([0,0.5,-2,2])
axis([-max(w),max(w),min(fai),max(fai)])
title('The phase response curve')
xlabel('Angle frequency'),ylabel('Phase')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -