hellojoshhhy
hellojoshhhy

Reputation: 958

How to convolve a function with delta function in Matlab?

as we know that another function convolve with delta function, the output will same as the function itself, for example

f(n) * δ(n) = f(n)

For example

n=-10:10;
h=[n>=0];
i=[(n-4)>=0];
f=h-i;

I get the function f(n), but how should I code the δ(n) in order to get a stem plot of f(n) * δ(n) ?

One more question, if we convolve one function itself repeatedly, what actually is happening? I try doing some chain convolution in Matlab like conv(conv(f,f,'same'),f,'same');, the stem plot are varying but i cant figure out the reason. Please assist, thank you.

Upvotes: 1

Views: 3236

Answers (2)

Christopher Crawford
Christopher Crawford

Reputation: 46

Convolution with delta shifts input by k-1 places:

delta=zeros(n); delta(k)=1 %k'th canonical basis vector

In higher dimensions, delta(ind(1),ind(2),..)=1

delta=zeros(dims); delta(num2cell(inds){:})=1 %canonical basis of matrices

Repeated convolution of the probability distribution of a random variable X results in the probability distribution of the sum of 'n' indpendent identically distributed copies X1+X2+..+Xn.

Upvotes: 0

Kami Kaze
Kami Kaze

Reputation: 2080

In discrete math the impulse is δ(0) = 1, δ(n) = 0 for n != 0.

If you convolve a function with itself, you just do exactly that. There is nothing special about it.

Convolve it with the mirrored(at the y-axis) function of itself would be an auto-correlation.

Upvotes: 1

Related Questions