实验二 卷积的实现
平台
第一大题
题目1
计算
f
1
=
g
10
(
t
−
5
)
f_1=g_{10}(t-5)
f1=g10(t−5)
与
f
2
=
g
24
(
t
−
12
)
f_2=g_{24}(t-12)
f2=g24(t−12)
的卷积结果.
code
%第一大题第1小问
%第一大题第1小问
f1=@(t)(heaviside(t+0)-heaviside(t-10));
f2=@(t)(heaviside(t+0)-heaviside(t-24));
f3=conv(f1(-10:30),f2(-10:30));
subplot(3,1,1);
ezplot(f1,[-10 30]);
subplot(3,1,2);
ezplot(f2,[-10 30]);
subplot(3,1,3);
x = -20:60;
plot(x,f3);
axis([-10,40,0,15]);
结果
题目2
计算
f
1
=
g
10
(
t
−
5
)
f_1=g_{10}(t-5)
f1=g10(t−5)
与
f
2
=
g
20
(
t
−
5
)
f_2=g_{20}(t-5)
f2=g20(t−5)
的卷积结果.
根据第一题修改一下参数就可以了
code
%第一大题第2小问
f1=@(t)(heaviside(t+0)-heaviside(t-10));
f2=@(t)(heaviside(t+5)-heaviside(t-15));
f3=conv(f1(-50:50),f2(-50:50));
subplot(3,1,1);
ezplot(f1,[-10 30]);
subplot(3,1,2);
ezplot(f2,[-10 30]);
subplot(3,1,3);
x = -100:100;
plot(x,f3);
axis([-10,30,0,15]);
结果
第二大题
题目
计算
f
1
=
g
10
(
t
−
5
)
f_1=g_{10}(t-5)
f1=g10(t−5)
和
f
2
=
e
−
t
u
(
t
)
f_2=e^{-t}u\left(t\right)
f2=e−tu(t)
code
t = 0:0.1:30;
f1=@(t)(heaviside(t+0)-heaviside(t-10));
f2=@(t)(exp(-t).*stepfun(t,0));
f3=conv(f1(-50:50),f2(-50:50));
subplot(3,1,1);
ezplot(f1,[-10 30]);
subplot(3,1,2);
ezplot(f2,[-10 30 0 1.2]);
subplot(3,1,3);
x = -100:100;
plot(x,f3);
axis([-10,30,0,2]);
结果
讲解
conv(x,h)卷积函数
w = conv(u,v) returns the convolution of vectors u and v. If u and v are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials.
ezplot()
ezplot(fun,[xmin,xmax]) plots fun(x) over the domain: xmin < x < xmax.
stepfun(T,T0)或heaviside(x)阶跃信号的绘制
matlab怎么画阶跃函数波形
stepfun(T,T0), where T is a monotonically increasing vector,
returns a vector the same length as T with zeros where T < T0
and ones where T >= T0.
heaviside(x)绘制门函数
heaviside(x) returns the value 0 for x < 0, 1 for x > 0, and 1/2 for x = 0.
f1=@(t)(heaviside(t+t1)-heaviside(t-t2));