How can I plot a sphere in 3D?

조회 수: 8 (최근 30일)
Pilar Jiménez
Pilar Jiménez 2016년 10월 5일
편집: Pilar Jiménez 2016년 10월 6일
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
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?
Pilar Jiménez
Pilar Jiménez 2016년 10월 6일
편집: Pilar Jiménez 2016년 10월 6일
I trying to show the values of a plane wave (that obtain with the equation that I named "wave" in the code) like a sphere. The idea is each iteration of the values of teta and phi represent a position of the wave and the result represent the radiation of an antenna in position x=1 and y=1, then my radiation is in full range of teta and phi that's the reason for the plot a sphere. I have defined these variables:
I hope you understand my idea.

댓글을 달려면 로그인하십시오.

답변 (1개)

Luca  Fenzi
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
Pilar Jiménez
Pilar Jiménez 2016년 10월 6일
편집: Pilar Jiménez 2016년 10월 6일
Thanks Luca, The problem is that the j is an imaginary unit not a real number, for this I can't give the value of 1. And at the end of my code I must have a sphere with the absolute results of my equation wave that is on a matrix with different dimensions matrix. I have defined these variables:
I=1; %establecida por usuario
freq=30000000; %30 Mhz - no. de ondas/seg
c=300000000000; %m/seg
wlong=c/freq; %m
k=2*pi/wlong; %no. onda

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by