# Calculate convolution of two given continuous signals in matlab

84 views (last 30 days)

Show older comments

##### 0 Comments

### Accepted Answer

Paul
on 5 Jun 2022

Closed form solution using symbolic math

syms t tau real

f1(t) = rectangularPulse(-5,5,t);

f2(t) = exp(-t)*heaviside(t);

y1(t) = int(f1(tau)*f2(t-tau),tau,-5,t)

figure;

fplot(y1(t),[-10 10])

hold on

Numerical solution using integral()

f1 = @(t) abs(t) <= 5;

f2 = @(t) exp(-t).*(t>=0);

y2 = @(t) integral(@(tau)(f1(tau).*f2(t-tau)),-5,t);

for tval = -7:2:10

plot(tval,y2(tval),'rx')

end

Numerical solution using conv(). Note that we have to settle for a vaue of t where we are willing to accept f2(t) = 0

dt = 0.1;

tval = -5:dt:15;

y3 = conv(f1(tval),f2(tval))*dt;

conv() assumes that the sequences start at t = 0, so we have to shift our time reference left by 5. Make dt smaller to improve the convolution sum approximation.

plot(tval-5,y3(1:numel(tval)),'ko')

legend('Closed Form','integral()','conv()','Location','NorthWest')

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!