子函数程序
function f=heaviside(t)
f=(t>0);
主程序 [分别对理想低通和实际低通作图: h(t)、|H(jω)|、φ(ω)]
%理想低通滤波器的单位冲激响应、幅频特性、相频特性。
syms t,f,w;
figure(1)
f=sin(t-1)/(t-1); Fw=fourier(f); %傅立叶变换
x=[-20:0.05:20]; fx=subs(f,t,x);
subplot(2,1,1);
plot(x,fx); %波形图 grid;
W=[-4:0.01:4]; FW=subs(Fw,w,W);
subplot(2,2,3);
plot(W,abs(FW)); %幅频特性
grid;
xlabel(' 频率');
ylabel(' 幅值');
subplot(2,2,4);
plot(W,angle(FW)); %相频特性
grid;
xlabel(' 频率');
ylabel(' 相位');
%RC 低通网络的单位冲激响应、幅频特性、相频特性 figure(2)
f=exp(-2*t)*sym('Heaviside(t)');
Fw=fourier(f); %傅立叶变换
x=[-4:0.02:4]; fx=subs(f,t,x);
subplot(2,1,1);
plot(x,fx); %波形图 grid;
W=[-4:0.02:4];
FW=subs(Fw,w,W);
subplot(2,2,3);
plot(W,abs(FW)); %幅频特性
grid;
xlabel(' 频率');
ylabel(' 幅值');
subplot(2,2,4); plot(W,angle(FW)); %相频特性
grid;
xlabel(' 频率');
ylabel(' 相位');
1、打开MATLAB 软件,建立一个M 文件。?
?
2、MATLAB 所在目录的\work 子目录下建立一个名为heaviside 的M 文件,创建子程序函
数。
3、建立一个新的M 文件,编写主程序并保存。