📄 frequs.m
字号:
% Name: frequs.m
% ===============================================================
clear,close all
num=input('input the numerator polynomial coefficient vector =:');
den=input('input the denominator polynomial coefficient vector =:');
reg=input('input the frequency region w=');
w=-3*reg:0.01*reg:3*reg;
p=roots(den); %求系统极点
q=roots(num); %求系统零点
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),'x');hold on; %画极点
plot(real(q),imag(q),'o');hold on; %画零点
grid on;
title('zero-pole and frequency response');
ylabel('zero-pole diagram');
[H,w]=freqs(num,den,w);
subplot(2,2,2)
plot(w,abs(H));
grid on;title('magnitude response');
axis([min(w),max(w),min(abs(H)),max(abs(H))])
subplot(2,2,4)
plot(w,angle(H));grid on;
xlabel('frequency radians/s ');title('phase response');
axis([min(w),max(w),min(angle(H)),max(angle(H))])
subplot(223)
t=0:0.01:4/0.1;
h=impulse(num,den,t);
plot(t,h)
title('Impulse response h(t)')
xlabel('Time t')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -