How to plot a 3d function on a sphere?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!