Convolution of a function g(x) and the dirac delta function.

10 views (last 30 days)
I want to get the convolution of a function g(x) and the dirac delta function. It should give me the function g(x) back but I'm unable to get it. When I get the stem plot of g(x) and the above convolution, I get different results. What will be the right way to go about doing this?

Accepted Answer

John D'Errico
John D'Errico on 1 Apr 2018
Edited: John D'Errico on 1 Apr 2018
Works for me.
G = rand(1,10);
Gconv = conv(G,1);
norm(G-Gconv)
ans =
0
WTP? If you did something different, then you need to show what you did, and ask what is wrong.
  3 Comments
Walter Roberson
Walter Roberson on 1 Apr 2018
[1] is the discrete version of the dirac delta: it is 1 at the center and 0 in the infinite extension to both sides.
John D'Errico
John D'Errico on 1 Apr 2018
Edited: John D'Errico on 1 Apr 2018
I gave you a convolution with a discrete approximation of a delta function. And I showed that it replicates the original function exactly.
Because conv is a discrete tool, working on discrete vector data, you need to use a unit approximation to the delta function. conv applies to vectors, not functions.
If you were doing a symbolic integration to perform the convolution, then the convolution between the function g(x) and dirac would be correct.
For example, had you tried this:
syms x y
int(sin(x)*dirac(y - x),[-inf,inf])
ans =
sin(y)
Then to no surprise, at least to me, it would work well enough.
You cannot mix the two though. Mixing apples and oranges will just drive you nuts. I prefer cashews. ;-)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!