📄 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 + -