How can I plot a sphere in 3D?
3 ビュー (過去 30 日間)
古いコメントを表示
I have to plot this equation to obtain a sphere
wave=I.*exp(j.*(((k.*x.*sin(TETA).*cos(PHI))))+((k.*y.*sin(TETA).*sin(PHI))))
but the comands mesh, surf, sphere not functioning me. I define the variables as following
puntos=200;
puntos_1=400;
teta=linspace(0,pi,puntos); %0 a 180°
phi=linspace(0,2*pi,puntos_1); %0 a 360°
[TETA,PHI]=meshgrid(teta,phi);
Could anyone help me, please?
2 件のコメント
David Goodmanson
2016 年 10 月 6 日
Are you trying to show the values of a plane wave on the surface of a sphere as the plane wave passes through that sphere? Or perhaps something different from that?
回答 (1 件)
Luca Fenzi
2016 年 10 月 6 日
This code works fine:
% PARAMETERS Of the model
I=1
x=1
y=1
k=1;
j=1;
%%Grid
puntos=200; puntos_1=400;
teta=linspace(0,pi,puntos); %0 a 180°
phi=linspace(0,2*pi,puntos_1); %0 a 360°
[TETA,PHI]=meshgrid(teta,phi);
% Model
wave=I.*exp(j.*(((k.*x.*sin(TETA).*cos(PHI))))+((k.*y.*sin(TETA).*sin(PHI))))
mesh(wave)
An other option should be instead of using teta,phi, you can use
[X,Y,Z]=sphere(N)
This will permit you to obtain a three dimensional grid of (N+1)x(N+1) points, but then your model wave must be changed from polar coordinate to Cartesian coordinate.
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!