% Matlab script to plot associated functions and polynomials % clear all; t = [-1:0.05:1]; P2 = legendre(2,t); P3 = legendre(10,t); P4 = legendre(40,t); P5 = legendre(50,t); % % Now do sectoral Harmonics (m=n) figure(1) plot(t,P2(3,:),'b'); hold on; plot(t,P3(11,:),'g'); plot(t,P4(41,:),'r'); plot(t,P5(51,:),'m'); title('Sectoral harmonics: Degrees 2-50, 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,'S2 b, S10 g, S40 r, S50 m') % % Now "normalize" the sectorals norm = zeros(5,1); i=2; norm(2) = sqrt(2*gamma(2*i+1)/(2*i+1)); i=10; norm(3) = sqrt(2*gamma(2*i+1)/(2*i+1)); i=40; norm(4) = sqrt(2*gamma(2*i+1)/(2*i+1)); i=50; norm(5) = sqrt(2*gamma(2*i+1)/(2*i+1)); figure(2) plot(t,P2(3,:)/norm(2),'b'); hold on; plot(t,P3(11,:)/norm(3),'g'); plot(t,P4(41,:)/norm(4),'r'); plot(t,P5(51,:)/norm(5),'m'); title('Normalized Sectoral harmonics: Degrees 2-50, 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,'S2 b, S10 g, S40 r, S50 m')