How to Plot a function on 3D-sphere?

I want to plot the function P of the equation shown. I have to obtan the following figure. I have already obtained all the inputs required by this function and have coded a program to get the figure but unable to get it.
N0=100;
r_med=0.5;
sigma_g=7;
N_ang=91;
[P11,P12,P33,P34,beta_s,alpha_c,beta_c] = ZK_W_Cloud_PhaseFunc(N0,r_med,sigma_g,N_ang)
theta=0:1:180;
beta1=180:1:360;
beta=2*beta1;
ph_ft1=P12.*cos(beta);
hph_ft=P11+ph_ft1
[x,y,z]=sphere
x1=x.*hph_ft;
y1=y.*hph_ft;
z1=z.*hph_ft;
S1=surf(x1,y1,z1)

Antworten (1)

Walter Roberson
Walter Roberson am 6 Apr. 2021

0 Stimmen

N0=100;
r_med=0.5;
sigma_g=7;
N_ang=91;
[P11,P12,P33,P34,beta_s,alpha_c,beta_c] = ZK_W_Cloud_PhaseFunc(N0,r_med,sigma_g,N_ang)
theta=0:1:180; %UNUSED
beta1=180:1:360;
beta=2*beta1;
ph_ft1=P12.*cosd(beta); %beta is degrees!
hph_ft=P11+ph_ft1
[x,y,z]=sphere
x1=x.*hph_ft;
y1=y.*hph_ft;
z1=z.*hph_ft;
S1=surf(x1,y1,z1)
Where is the alpha? Where is the sind(2*beta) ? Or all of the other variables??
It is not a good idea to use variable names that are completely different than the equations.

3 Kommentare

Wiqas Ahmad
Wiqas Ahmad am 6 Apr. 2021
Bearbeitet: Wiqas Ahmad am 6 Apr. 2021
N0=100;
r_med=0.5;
sigma_g=7;
N_ang=91;
[P11,P12,P33,P34,beta_s,alpha_c,beta_c] = ZK_W_Cloud_PhaseFunc(N0,r_med,sigma_g,N_ang)% P11 is s11, and P12 is s12
theta=0:1:180;% angle alpha
beta1=180:1:360; %angle beta
beta=2*beta1;
ph_ft1=P12.*cosd(beta); %beta is degrees!
hph_ft=P11+ph_ft1 % This is the function I have to plot
[x,y,z]=sphere
x1=x.*hph_ft;
y1=y.*hph_ft;
z1=z.*hph_ft;
S1=surf(x1,y1,z1)
Oh sorry, I didn't interpret my question accurately. Actually we have two angles in the function ( alpha and beta).I refer angle alpha as theta=0:1:180 and angle beta as beta1=180:1:360, The s11 and s12 in the function are P11 and P12. We can skip P33 and P34 for the time being and Q0=1 and U0=0. The three variables (beta_s,alpha_c,beta_c) are contants. I can obtain the outputs [P11,P12,P33,P34,beta_s,alpha_c,beta_c] from the file ZK_W_Cloud_PhaseFunc by using inputs (N0,r_med,sigma_g,N_ang). I hope it will make sense now
Walter Roberson
Walter Roberson am 6 Apr. 2021
You added a small number of constants, but I do not see the term?
It is not a good idea to use variable names that are completely different than the equations. Make it easy for anyone who is looking at the equation to see that your implementation matches the equation.
Wiqas Ahmad
Wiqas Ahmad am 9 Apr. 2021
Bearbeitet: Wiqas Ahmad am 9 Apr. 2021
I modified my question and now the code is is according to the question. Hope it will be clear now
N0=100;
r_med=0.5;
sigma_g=7;
N_ang=91;
[P11,P12,P33,P34,beta_s,alpha_c,beta_c] = ZK_W_Cloud_PhaseFunc(N0,r_med,sigma_g,N_ang)
alpha=0:1:180;% angle alpha
beta=180:1:360; %angle beta
ph_ft(alpha,beta)=P11(alpha)+P12(alpha).*(cosd(2*beta)); %beta is in degrees! I have to plot this function
[x,y,z]=sphere
x1=x.*ph_ft;
y1=y.*ph_ft;
z1=z.*ph_ft;
S1=surf(x1,y1,z1)

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 6 Apr. 2021

Bearbeitet:

am 9 Apr. 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by