Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Electromagnetic waves report

ECE331
Group 3 Section 2
Rady Magdy Melik 1805504
Mahmoud Kamal Mahmoud 1804630
Youssef Amr Hussein 1809078
Mahmoud Fathy Kotb 1805552
Mahmoud ehab morsy 1804667
Matlab code:
clear all
A0 = 1;
lamda=2.4e-6; %lamda= 2.4 micro m
k =2*pi/lamda;
w0=2e-5;
z0 = pi*w0^2/lamda;
N=sqrt(2)*pi/k; %sampling period
L= 8e-05;
x = -L:N:L
y = -L:N:L;
[X, Y] = meshgrid(x,y);
p=sqrt(X.^2 + Y.^2);
gaussian_beam =A0*exp(-(p.^2)/w0^2);
M=length(x);
% to get input intensity
figure(1);
subplot(1,2,1);
plot(x,abs(gaussian_beam(:,round(M/2))).^2); % to extract
the first half of the matrix (y=0)
title('the input intensity of gaussian beam');
subplot(1,2,2);
plot(X,Y)
imagesc(x,y,abs(gaussian_beam).^2)
%to get fourrier transform
Uf=fftshift(fft2(gaussian_beam));

dkx=2*pi/ N;
kx = linspace(-dkx/2,dkx/2,M);
ky = kx;
[KX,KY]=meshgrid(kx,ky);
kz=k -(KY.^2+KX.^2)/(2*k);
%transfer functions
H_z0 = exp(-kz.*z0*1i ) ;
H_halfz0 = exp(-kz.*(0.5*z0)*1i ) ;
H_2z0 = exp(-kz.*(2*z0)*1i ) ;

TF_z0=Uf.*H_z0;
TF_halfz0=Uf.*H_halfz0;
TF_2z0=Uf.*H_2z0;
%getting the inverse fourrier transform
U_inv_z0=ifft2(ifftshift(TF_z0));
U_inv_halfz0=ifft2(ifftshift(TF_halfz0));
U_inv_2z0=ifft2(ifftshift(TF_2z0));
figure(2);
subplot(2,3,1);
plot(x,abs(U_inv_z0(:,round(M/2))).^2)
xlim([-L L]);
ylim([0 1]);
title('Output intensity at Z0');
subplot(2,3,4);
imagesc(x,y,abs(U_inv_z0).^2)
subplot(2,3,2);
plot(x,abs(U_inv_halfz0(:,round(M/2))).^2)
xlim([-L L]);
ylim([0 1]);
title('Output intensity at 0.5 Z0');
subplot(2,3,5);
imagesc(x,y,abs(U_inv_halfz0).^2)
subplot(2,3,3);
plot(x,abs(U_inv_2z0(:,round(M/2))).^2)
xlim([-L L]);
ylim([0 1]);
title('Output intensity at 2 Z0');
subplot(2,3,6);
imagesc(x,y,abs(U_inv_2z0).^2)
figure(3)
subplot(1,3,1)
mesh(X,Y,abs(U_inv_z0).^2)
subplot(1,3,2)
mesh(X,Y,abs(U_inv_halfz0).^2)
subplot(1,3,3)
mesh(X,Y,abs(U_inv_2z0).^2)
Figures:
The input intensities of the gaussian beam
The output intensities at Z0 , 2Z0 and 0.5Z0:

You might also like