% Matlab script to plot associated functions and polynomials % clear all; t = [-1:0.05:1]; P2 = legendre(2,t); P3 = legendre(3,t); P4 = legendre(4,t); P5 = legendre(5,t); % % Now make plots clf figure(1) plot(t,P2(1,:),'b'); hold on; plot(t,P3(1,:),'g'); plot(t,P4(1,:),'r'); plot(t,P5(1,:),'m'); title('Polynomials: Degrees 2-5; Order 0') xlabel('Cos(theta)'); ylabel('Legendre Function') yt = get(gca,'YLIM'); ypos = yt(1) + (yt(2)-yt(1))*0.05; text(-0.95,ypos,'P2 b, P3 g, P4 r, P5 m') % % Now do m=1 figure(2) plot(t,P2(2,:),'b'); hold on; plot(t,P3(2,:),'g'); plot(t,P4(3,:),'r'); plot(t,P5(4,:),'m'); title('Asociated Function: Degrees 2-5, order 1') xlabel('Cos(theta)'); ylabel('Legendre Function') yt = get(gca,'YLIM'); ypos = yt(1) + (yt(2)-yt(1))*0.05; text(-0.95,ypos,'P2 b, P3 g, P4 r, P5 m') % Now do m=2 figure(3) plot(t,P2(3,:),'b'); hold on; plot(t,P3(3,:),'g'); plot(t,P4(3,:),'r'); plot(t,P5(3,:),'m'); title('Asociated Function: Degrees 2-5, order 2') xlabel('Cos(theta)'); ylabel('Legendre Function') yt = get(gca,'YLIM'); ypos = yt(1) + (yt(2)-yt(1))*0.05; text(-0.95,ypos,'P2 b, P3 g, P4 r, P5 m') % Now do m=3 figure(4) plot(t,P3(3,:),'g');hold on; plot(t,P4(3,:),'r'); plot(t,P5(3,:),'m'); title('Asociated Function: Degrees 2-5, order 3') xlabel('Cos(theta)'); ylabel('Legendre Function') yt = get(gca,'YLIM'); ypos = yt(1) + (yt(2)-yt(1))*0.05; text(-0.95,ypos,'P3 g, P4 r, P5 m') % Now do m=4 figure(5) plot(t,P4(3,:),'r');hold on; plot(t,P5(3,:),'m'); title('Asociated Functions: Degrees 2-5, order 4') xlabel('Cos(theta)'); ylabel('Legendre Function') yt = get(gca,'YLIM'); ypos = yt(1) + (yt(2)-yt(1))*0.05; text(-0.95,ypos,'P4 r, P5 m') % Now do sectoral Harmonics (m=n) figure(6) plot(t,P2(3,:),'b'); hold on; plot(t,P3(4,:),'g'); plot(t,P4(5,:),'r'); plot(t,P5(6,:),'m'); title('Sectoral harmonics: Degrees 2-5, order m=n') xlabel('Cos(theta)'); ylabel('Legendre Function') yt = get(gca,'YLIM'); ypos = yt(1) + (yt(2)-yt(1))*0.05; text(-0.95,ypos,'P2 b, P3 g, P4 r, P5 m') % % Now "normalize" the sectorals for i = 2:5 norm(i) = sqrt(2*gamma(2*i+1)/(2*i+1)); end figure(7) plot(t,P2(3,:)/norm(2),'b'); hold on; plot(t,P3(4,:)/norm(3),'g'); plot(t,P4(5,:)/norm(4),'r'); plot(t,P5(6,:)/norm(5),'m'); title('Normalized Sectoral harmonics: Degrees 2-5, order m=n') xlabel('Cos(theta)'); ylabel('Legendre Function') yt = get(gca,'YLIM'); ypos = yt(1) + (yt(2)-yt(1))*0.05; text(-0.95,ypos,'P2 b, P3 g, P4 r, P5 m')