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

93 views (last 30 days)
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])

Answers (3)

MUHAMMAD EZARISMA AFIF WISYU HARDI
Edited: Walter Roberson on 31 Dec 2020
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 on 31 Dec 2020
Edited: David Goodmanson on 31 Dec 2020
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 on 31 Dec 2020
Edited: Walter Roberson on 31 Dec 2020
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

Products

Community Treasure Hunt

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

Start Hunting!