How to plot a 3d function on a sphere?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I want to plot the following function on a sphere to obtain the figures below. The function is
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/675663/image.png)
P11 and P12 are two row vectors in my directory with sizes
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/675668/image.png)
The required figures are
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/675673/image.png)
The first figure is generated by using the values [1,1,0,0] and the second is generated by [1,0,0,1] of the vector [I0,Q0,U0,V0]. My coded program and its output are
clear all;
clc;
%% ------------------------------Program-------------------------------------
N0=100;
r_med=[1];
sigma_g=7;
N_ang=91;
theta=1:1:181;
phi=1:1:360;
for i=1:length(r_med)
[P11(i,:),P12(i,:),P33(i,:),P34(i,:),~,~,~] = ZK_W_Cloud_PhaseFunc(N0,r_med(i),sigma_g,N_ang)
end
figure
hold on
[theta,phi]=meshgrid(theta,phi);
P122=P12(i,:).*cos(2*phi);
P(i,:)=P11(i,:)+P122(i,:);
x=P(i,:).*cos(phi).*sin(theta);
y=P(i,:).*sin(phi).*sin(theta);
z=P(i,:).*cos(theta);
plot3(x,y,z)
xlabel('X');ylabel('Y');zlabel('Z');
%%%-------------------------------------------------------------------%%%
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/675678/image.png)
0 Commenti
Risposte (1)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!