The matrix P_bar is 3 dimensional. It has upper diagonal elements all zeros. In other words, if we consider it as a rectangular shaped prism, upper half has been removed or has null values, and using recursion lower part has been created.
I just want to see my matrix (P_bar) in 3D (If possible, all values inside that matrix in that plot with different colours).
Please help me,… Thanks in advance.
The code is given below:
d% Legendre Polynomials
clc; clear all; close all;L_max=input('Enter the Degree (L_max) ='); M=input('Enter the Oder (M) =');if M>L_max fprintf('\n\n\n\t\tError!\n\nPlease enter Degree>Order!\n'); quit cancel;else if M==0 Delta_M=1; else Delta_M=0; end theta=[0:1:180]'; % Co-latitude matix with 1 degree interval
Cos_theta(1,1,1:181)=cosd(theta); Sin_theta(1,1,1:181)=sind(theta); Cot_theta(1,1,1:181)=cotd(theta); P_bar(1,1,1:181)=1/4*pi; % P_bar(0,0)----> Eqution(4)
for m=1:M % P_bar(m,m)----> Eqution(5)
P_bar(m+1,m+1,1:181)= Sin_theta *sqrt( ((2*(m-1)+3)*(1+ Delta_M))/ (2*(m-1)+2) ).*P_bar(m,m,1:181); % P_bar(m+1,m)----> Eqution(6)
P_bar(m+1,m,1:181) = Cot_theta *sqrt( (2*(m-1)+2) / (1+ Delta_M) ).*P_bar(m+1,m+1,1:181); % P_bar(l+1,m)----> Eqution(7)
for l=(m+1):L_max P_bar(l+1,m,1:181) = Cos_theta *sqrt((2*(l-1)+3) * (2*(l-1)+1)/ ((l-1)-(m-1)+1) * ((l-1)+(m-1)+1)) .*P_bar(l,m,1:181)-( sqrt((2*(l-1)+3) * ((l-1)*(l-1)-(m-1)*(m-1))/ (2*(l-1)-1) * (((l-1)+1) * ((l-1)+1) -(m-1)*(m-1))) *P_bar(l-1,m,1:181) ); end end figure; plot(theta,P_bar(:,1:181),'linewidth',1.4);end
Best Answer