How to plot a 3d function on a sphere?

6 ビュー (過去 30 日間)
Wiqas Ahmad
Wiqas Ahmad 2021 年 7 月 6 日
回答済み: Jai Khurana 2021 年 7 月 6 日
I want to plot the following function on a sphere to obtain the figures below. The function is
P11 and P12 are two row vectors in my directory with sizes
.
The required figures are
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');
%%%-------------------------------------------------------------------%%%

回答 (1 件)

Jai Khurana
Jai Khurana 2021 年 7 月 6 日
Hi Wiqas,
Hope it helps.

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by