Convolution of two symfuns

156 views (last 30 days)
Mihnea Cristian Marin
Mihnea Cristian Marin on 10 Jan 2018
Answered: Zane Cook on 18 Apr 2022
Hello everyone,
I have an assignment which tells me to plot y(t), where y(t) is the convolution of x1(t) and x2(t). These are two symbolic functions declared this way:
x1 = symfun(29*t^2 - 165*t + 420, t)
x2 = symfun(symsum((-1)^k*dirac(t - 24*k), k, 0, 100) + symsum(1/(-1)^k*dirac(- t - 24*k), k, 1, 100), t)
I tried the following formula but it sends me an error:
y = symfun(conv(x1(t),x2(t), 'same'), t)
and the error is this one:
Undefined function 'conv2' for input arguments of type 'sym'.
Error in conv (line 40)
c = conv2(a(:),b(:),shape);
Can anyone help me?

Answers (3)

Walter Roberson
Walter Roberson on 10 Jan 2018
You need to use the convolution integral transform https://en.wikipedia.org/wiki/Convolution#Definition
conv() is only for discrete convolution, whereas you have a continuous system.

Zane Cook
Zane Cook on 18 Apr 2022
I know this post is old, but maybe this will help someone else that is trying to do this.
The easiest way I have found to do this is by using the fact that convolution in the time domain is multiplication in the frequency domain, and vice versa. You can take the fourier transform of your functions, multiply them, then take the inverse fourier and use fplot.
y=ifourier(fourier(x1)*fourier(x2))
fplot(y)

Torsten
Torsten on 10 Jan 2018
For comparison:
Result is
29*t^2-165*t+33408*(2*kend-1)+420
with kend = 100 in this case.
kend must be an even integer.
Best wishes
Torsten.

Community Treasure Hunt

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

Start Hunting!