0% found this document useful (0 votes)
93 views

Optical Communication - Code For Matlab

This MATLAB code calculates and plots the modes of a cylindrical waveguide. It first defines variables like the waveguide radius a and mesh grid points r and phi. It then calculates the zeros of Bessel functions J0, J1, and J2 to find the modes m0, m1, and m2. Finally, it plots the electric field distribution z for each mode m=0,1,2 by drawing 3D mesh plots with the Bessel function, r, and phi variables.

Uploaded by

Akhil Dixit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views

Optical Communication - Code For Matlab

This MATLAB code calculates and plots the modes of a cylindrical waveguide. It first defines variables like the waveguide radius a and mesh grid points r and phi. It then calculates the zeros of Bessel functions J0, J1, and J2 to find the modes m0, m1, and m2. Finally, it plots the electric field distribution z for each mode m=0,1,2 by drawing 3D mesh plots with the Bessel function, r, and phi variables.

Uploaded by

Akhil Dixit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

%Anshul Dagar(2k16/ec/019)

%Akhil Dixit(2k16/ec/005)

%Akhil Kumar(2k16/ec/006)

clc;

clear all;

close all;

v=6.5;

%mesh draw points r & phi

r=linspace(0,a,400);

phi=linspace(0,2*pi,400);

[r,phi]=meshgrid(r,phi);

%calculate the modes

m0=[];m1=[];m2=[];

for x=1:10

m0(end+1)=fzero(@(x)besselj(0,x),[x-1 x]*pi);

if x*pi>v

break;

end

end

for x=1:10

t=fzero(@(x)besselj(1,x),[x-1 x]*pi);

if t>0

m1(end+1)=t;

end

if x*pi>v

break;

end

end

for x=1:10

t=fzero(@(x)besselj(2,x),[x-1 x]*pi);

if t>0

m2(end+1)=t;

end
if x*pi>v

break;

end

end

%draw modes for m=0

for i=1:length(m0)

z=besselj(0,m0(i)*r/a).*cos(0.*phi);

x=r.*cos(phi);

y=r.*sin(phi);

figure

mesh(x,y,z.^2);

end

%draw modes for m=1

for i=1:length(m1)

z=besselj(1,m1(i)*r/a).*cos(1.*phi);

x=r.*cos(phi);

y=r.*sin(phi);

figure

mesh(x,y,z.^2);

end

%draw modes for m=2

for i=1:length(m2)

z=besselj(2,m2(i)*r/a).*cos(2.*phi);

x=r.*cos(phi);

y=r.*sin(phi);

figure

mesh(x,y,z.^2);

end

You might also like