Fresnel-like diffraction using linear convolution

Hi guys,
I'm trying to calculate the convolution of a Gaussian function and a parabolic wavefront (like in Fresnel diffraction):
x=linspace(-30,30,100);
w=0.5;
k=1;
A=exp(-x.^2/w^2);
B=exp(-ii*k*x.^2);
C=conv(A,B);
plot(abs(C))
My question is, does the above code calculate the linear convolution (and not the circular convolution)?
The reason I ask is that I seems that C is composed of a number of peaks depending on the value of k. I wasn't expecting that, but then again my intuition is often defeated by such problems.
Cheers, David

Answers (1)

Hello, perhaps this answer is late, but it might help someone else.
I have tried your code and I don't know much about Fresnel diffraction, but I can only see one peak. You never provided a value for ii, but it doesn't seem to matter in my case.
Instead, to answer what I do know about, conv is producing a linear convolution. To convince yourself you can check the definition or use FFT with zero padding.
So,
n=5;
a = rand(1,n);
tmp1 = conv(a,a); %Matlab conv
tmp2 = ifft(fft([a, 0*a]).*fft([a, 0*a])); %FFT with zero padding = linear convolution
and the results are that tmp1(1:n) and tmp2(1:n) are identical. So, conv is thus convolving linearly, just like for a zero padded FFT.

3 Comments

Hi Matz,
Thanks for taking a look at this for me. The code I pasted in my original question was missing one line:
ii=sqrt(-1);
You are quite right in saying if ii were a real number C returns a single peak. However when ii is the imaginary unit the multiple peaks emerge. I'm not sure if this is a computational quirk or that my understanding of the mathematics is lacking. Performing the convolution (analytically) in Mathematica does yield a single peak though...
Cheers, David
Instead of your own ‘ii’ variable, use 1i. That is the preferred MATLAB designation for the imaginary operator.
Hi Star Strider,
Yeah, I recently discovered 1i performs the same function. I'll adopt that in the future.
David

Sign in to comment.

Asked:

on 26 Jun 2014

Commented:

on 5 Jul 2014

Community Treasure Hunt

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

Start Hunting!