convolution of exponential with unit step ... using conv command

57 次查看(过去 30 天)
Hi everybody,
Suppose we have two signals:
u(t) : unit step function and h(t) = exp(-t) * u(t)
Let us calculate their convolution. Doing that on paper is pretty easy, the result will be y(t) = (1-exp(-t)) * u(t). i.e the function will increase till it reaches the value of 1 and then it becomes constant = 1.
The big question is that why the following code produces wrong answer after time of 10s (this time is the length of the original signals)? In other words, why the result starts decaying after this time instant and reaches zero ?!
Code:
t = -1:0.01:10;
u = heaviside(t);
u(u==0.5) = 1;
subplot(221), plot(t,u), axis([-1 10 -.5 1.5])
h = exp(-t).* u;
subplot(222), plot(t,h), axis([-1 10 -.5 1.5])
C = conv(h,u)/100;
tc = [-200:length(C)-1-200]/100;
subplot(2,2,3:4), plot(tc,C), axis([-1 20 -.5 1.5])

回答(3 个)

MUHAMMAD EZARISMA AFIF WISYU HARDI
编辑:Walter Roberson 2020-12-31
t = -1:0.01:10;
u = heaviside(t);
u(u==0.5) = 1;
subplot(221), plot(t,u), axis([-1 10 -.5 1.5])
h = exp(-t).* u;
subplot(222), plot(t,h), axis([-1 10 -.5 1.5])
C = conv(h,u)/100;
tc = [-200:length(C)-1-200]/100;
subplot(2,2,3:4), plot(tc,C), axis([-1 20 -.5 1.5])

David Goodmanson
David Goodmanson 2020-12-31
编辑:David Goodmanson 2020-12-31
Hi Muhammed,
since your reply is a copy of the the orignal code, nothing changes. Anyway, the reason for the effect is that when t stops at t = 10, the heaviside function effectively becomes the rectangle function U = heaviside(t).*heaviside(10-t). The convultion does exactly what it is supposed to with that, and gives the same result as you would get by doing the convolution of h with U.

Walter Roberson
Walter Roberson 2020-12-31
编辑:Walter Roberson 2020-12-31
t = -1:0.01:10;
u = heaviside(t);
u(u==0.5) = 1;
subplot(2,2,1); plot(t,u); axis([-1 10 -.5 1.5]);
h = exp(-t).* u;
subplot(2,2,2); plot(t,h); axis([-1 10 -.5 1.5]);
C = conv(h,u)/100;
tc = [-200:length(C)-1-200]/100;
subplot(2,2,3); plot(tc,C); axis([-1 20 -.5 1.5]);
Cv = conv(fliplr(h), u, 'same')/100;
subplot(2,2,4); plot(Cv)
Remember that convolution implicitly reverses one of the functions

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by