stepres.m
来自「经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助」· M 代码 · 共 36 行
M
36 行
% The step response and the impulse response of an ideal lowpass filter
% Name:stepres
% tao: the time delay of the filter.
% t0~t1:the time range.
% h(t):the impulse response.
% r(t):the step response.
% the cutoff frequency in terms of n*pi.
clear,close all,
p=0.01;
t0=-10;
t1=10;
t=t0:p:t1;
tao=input('input the time delay tao=:');
wc=input('input the cutoff frequency of the lowpass filter wc=:');
%h=(wc/pi)*sin(wc*(t-tao)+eps)./(wc*(t-tao)+eps);
h=(wc/pi)*sinc(wc*(t-tao)/pi);
s=p*conv(h,u(t));
l=length(s);
m=2*t0:p:t0-p;
n=t1+p:p:2*t1;
m1=zeros(1,abs(t0/p));
n1=zeros(1,abs(t1/p));
lm=length(m1);
ln=length(n1);
s=s([lm+1:l-ln]);
clf;
subplot(2,1,1)
plot(t,h);grid on;title('The impulse response h(t)')
axis([-3,3,1.2*min(h),1.1*max(h)])
subplot(2,1,2)
plot(t,s);grid on;title('The step response r(t)')
axis([-3,3,1.2*min(s),1.1*max(s)])
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?