% Book: Laser Electronics by Verdeyen
% Problem: Chapter 3 problem 5
% Script Author: meg noah meg_noah@student.uml.edu
function Lasers_Ch3_Pr5
textsize = 10;titlesize = 14;axissize = 12;
nx=200;gain=8.0/nx;offset=-gain*nx/2.0;
x = zeros(nx);for i = 1:nx;x(i) = i*gain+offset;end;
E00 = exp(-x.^2);
E10 = sqrt(.5).*sqrt(2.0).*x.*exp(-x.^2)
axes('fontsize',axissize,'position',[.15 .19 .81 .7]);
axis([x(1) x(nx) -0.5 1.5]);
ifigure = 1;figure(ifigure);cla;
title(['E field and Intensity'],'fontsize',titlesize);
ylabel('Intensity [arbitrary units]','fontsize',titlesize);
xlabel('x [arbitrary units]','fontsize',titlesize);hold on;
h1=plot(x,E00,'color',[0 .7 0]);
h1=plot(x,E10,'b',x,(E00+E10).^2,'r',x,E00.^2+E10.^2,'k');
h=legend(['E TEM_0_0          ';'E TEM_1_0          ';
    'Intensity (E0+E1)^2';'Intensity E0^2+E1^2'],2);
lines = findobj(get(h,'children'),'type','line');
set(lines(1),'color',[0 .7  0]);
set(lines(2),'color',[0  0 0]);
set(lines(4),'color',[.7 0  0]);
set(lines(6),'color',[0 0 .7]);
