How to plot the convolution of 2 functions

10 views (last 30 days)
I'm writing a report in which i'm writing a section on convolution and all the great things it can do... I am trying to create a demonstration of the operation in which i use matlab figures to visualise the operation however I'm not totally convinced by the result, as I've read that the conv function is only applicable to vectors and not functions, however, the result makes sense to me, was hoping for some confirmation/pointing in the right direction.
x = 0:1:10;
y = x.^2;
plot(x,y)
title('Line Plot of function 1: y = x^2 between 0 and 10')
xlabel('x')
ylabel('y')
x1=0:1:10
y1= 20-2*x1
figure
plot(x1,y1)
title('Line Plot of function 2: y = 20-2x between 0 and 10')
xlabel('x')
ylabel('y')
C=conv(y,y1,'same')
figure
plot(C)
title('Line Plot of the convolution of function 1 with function 2')
xlabel('x')
ylabel('y')

Accepted Answer

Rik
Rik on 7 Jul 2021
You didn't do the convolution on a function. However, since the vectors you did use are the y values of functions (with a shared x), the result is equivalent.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!