% Book: Laser Electronics by Verdeyen
% Problem: Chapter 5 problem 4a
% Script Author: meg noah meg_noah@student.uml.edu
function Lasers_Ch5_Pr4a
% plot the spot size at R and z=0 for Problem 5.4
textsize = 10;titlesize = 14;axissize = 12;
pi = 4.0*atan(1.0);
nx=200;d=0.5;R=20.0;L=632.8e-9;A=L*sqrt(R/2.0)/pi;
R2=2.0*R;
d = zeros(nx);for i = 1:nx;d(i) = 2*R*i/(nx);end;
% at mirror R1 or R2 at d/2
w2 = 1000.0*sqrt(A*sqrt(d)./sqrt(1-d./R2));
% at center z=0
w2_0 = 1000.0*sqrt(A*sqrt(d).*sqrt(1-d./R2));
axes('fontsize',axissize,'position',[.15 .19 .81 .7]);
ifigure = 1;figure(ifigure);cla;
title(['Spot Sizes in Cavity R=20m \lambda_0=632.8 nm'], ...
    'fontsize',titlesize);
ylabel('w [mm]','fontsize',titlesize);
xlabel('d [m]','fontsize',titlesize);hold on;
h1=plot(d,w2,'color',[0 .7 0]);
h1=plot(d,w2_0,'b');
h=legend(['Spot Size on R_1 or R_2';'Spot Size at z=0       ']);
lines = findobj(get(h,'children'),'type','line');
set(lines(1),'color',[0 .7  0]);
set(lines(2),'color',[0  0 1]);
