User:Shivaniandsingh
Intensity Patterns of any Hermite Gaussian Modes of Spherical Mirror Resonator (Contour )
lambda = 694.3 ; %nm
% The parameters for the gaussian beam
z0 = 1; %Rayleigh range in mm
W0 = sqrt(lambda*z0/pi); % Beam waist radius in μm
z = 1e-9; %mm
W = @(z)W0*sqrt(1+(z/z0)^2); %micro-meter
% The coefficients for the Hermite-Gaussian (HG) beam of order (l,m)
A = [ 1 2 3 4; 1 1 1 0.1; 0.1 0.2 0.3 1; 0.4 0 .2 0.5];
x = -30:1:30 ; %mm
y = -30:1:30; %mm
[X Y] = meshgrid(x,y);
U = zeros(length(X),1);
Utemp = zeros(length(X),1);
Utemp2 = zeros(length(X),1);
u = sqrt(2)*X/W(z);
v = sqrt(2)*Y/W(z);
p = 'Enter the l value for required mode you want to see? ';
l = input(p)+1
q = 'Enter the m value for required mode you want to see? ';
m = input(q)+1
Utemp2 = (W0/W(z))*(hermiteH(l-1,u)).*exp(-u.^2/2);
Utemp = Utemp2.*(hermiteH(m-1,v)).*exp(-v.^2/2);
Utemp = A(l,m)*Utemp;
U = U + Utemp;
f=figure;
contourf(X,Y,abs(U.^2),90);
colormap(f,hot);
surf(X,Y,abs(U.^2));
xlabel('x-axis(mm)')
ylabel('y-axis(mm)')
zlabel('Intensity')
I have created for first few Modes , you can extend the size of A matrix of coefficients for further modes
<ref>https://www.mathworks.com/matlabcentral/fileexchange/71642-hermite-gaussian-beam</