title('f2信号波形'); grid on;
xlabel('时间t/s'); axis([0 7 0 2]); subplot(3,1,3); plot(t3,w);
title('f1和f2信号卷积结果'); xlabel('时间t'); grid on;
先建立函数再用conv函数实现卷积
3. 调试例1-38、例1-39、例1-40、例1-41 和例1-42,分析说明各题采用什么实现方法及其注意事项。 例1-38
syms tau w
Gt=sym('2*(heaviside(tau+1)-heaviside(tau-1))'); Fw=fourier(Gt,tau,w); 对门函数作傅里叶变换 ezplot(Fw,[-10*pi 10*pi]); axis([-10*pi 10*pi -1 5]); grid on;
例1-39
syms t v w x;
x=1/2*exp(-2*t)*sym('heaviside(t)'); F=fourier(x); subplot(2,1,1); ezplot(x); subplot(2,1,2); ezplot('abs(F)');
例1-40
R=0.1; t=-2:R:2;
ft=[zeros(1,10),ones(1,21),zeros(1,10)]; W1=10*pi;
N=500;k=0;N;w=k*W1/N; Fw=ft*exp(-j*t'*w)*R; FRw=abs(Fw);
W=[-flipir(w),w(2:501)]; FW=[flipir(FRw),FRw(2:501)]; subplot(2,1,1); plot(t,ft);
axis([-5 5 -0.5 1.5]); grid on;
xlabel('t');ylabel('f(t)'); title('f(t)=u(t+1)-u(t-1)'); subplot(2,1,2); plot(W,FW); grid on;
xlabel('W');ylabel('F(W)'); title('f(t)的振幅频谱图');
例 1-41:程序如下: close all;clear;clc;
tau=2; T0=4; m=15; E=2;
t1=-tau/2:0.01:tau/2;
t2=tau/2:0.01:(T0-tau/2);
t=[(t1-T0)';(t2-T0)';t1';t2';(t1+T0)']; n1=length(t1); n2=length(t2);
f=E*[ones(n1,1);zeros(n2,1);ones(n1,1);zeros(n2,1);ones(n1,1)];
y=zeros(m+1,length(t));
y(m+1,:)=f';
figure(1);
h=plot(t,y(m+1,:));
axis([-(T0+tau/2)-0.5,(T0+tau/2)+0.5,0,2.5]);
set(gca,'XTick',-T0-1:1:T0+1); title('矩形信号'); grid on; figure(2); a=tau/T0;
freq=[-20:1:20];
mag=abs(E*a*sinc(a*freq)); h=stem(freq,mag); x=E*a*ones(size(t)); title('离散幅度谱'); xlabel('f');
axis([-20,20,0,1.5]); grid on; for k=1:m
x=x+2*E*a*sinc(a*k)*cos(2*pi*t*k/T0); y(k,:)=x; end
figure(3);
plot(t,y(m+1,:)); hold on;
h=plot(t,y(k,:)); grid on;
axis([-(T0+tau/2)-0.5,(T0+tau/2)+0.5,-0.5,2.5]);
相关推荐: