% Book: Laser Electronics by Verdeyen
% Problem: Chapter 5 problem 4
% Script Author: meg noah meg_noah@student.uml.edu
function Lasers_Ch5_Pr4
textsize = 10;titlesize = 14;axissize = 12;
nx=200;
x = zeros(nx);for i = 1:nx;x(i) = i/nx;end;
% at mirror R1 or R2 at d/2
w2 = sqrt(x)./sqrt(1-x);
% at center z=0
w2_0 = sqrt(x).*sqrt(1-x);
axes('fontsize',axissize,'position',[.15 .19 .81 .7]);
ifigure = 1;figure(ifigure);cla;
title(['Spot Sizes in Cavity'],'fontsize',titlesize);
ylabel('w^2 [\lambda/\pi (dR)^0^.^5]','fontsize',titlesize);
xlabel('d/2R','fontsize',titlesize);hold on;
h1=plot(x,w2,'color',[0 .7 0]);
h1=plot(x,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]);
