Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plotting points in spherical surface

Subject: plotting points in spherical surface

From: Kate

Date: 24 Sep, 2010 02:46:05

Message: 1 of 5

hi guys,

i have azimuth and elevation values as follows:

[azimuth elevation]= [ 0.2369082089522 1.70518375159222
                             -2.90737451551037 1.42445621521504
                             -2.97765472371756 1.32636668816057
                             -2.9832318553616 1.36219399418402]

i assume distance from center of sphere ,i.e r =5.

how can i plot these 4 points on a sphere?

thanks again
kate

Subject: plotting points in spherical surface

From: Roger Stafford

Date: 24 Sep, 2010 03:17:06

Message: 2 of 5

"Kate " <chino_tones@hotmail.com> wrote in message <i7h3dd$t55$1@fred.mathworks.com>...
> hi guys,
>
> i have azimuth and elevation values as follows:
>
> [azimuth elevation]= [ 0.2369082089522 1.70518375159222
> -2.90737451551037 1.42445621521504
> -2.97765472371756 1.32636668816057
> -2.9832318553616 1.36219399418402]
>
> i assume distance from center of sphere ,i.e r =5.
>
> how can i plot these 4 points on a sphere?
>
> thanks again
> kate
- - - - - - - -
  It depends on how you define azimuth and elevation in terms of the x, y, z axes of a plot. The definition used by the matlab 'view' function is: "The azimuth, az, is the horizontal rotation about the z-axis as measured in degrees from the negative y-axis. Positive values indicate counterclockwise rotation of the viewpoint. el is the vertical elevation of the viewpoint in degrees. Positive values of elevation correspond to moving above the object; negative values correspond to moving below the object."

  It seems clear that your values are in radians so I have altered the following to use radians. It is easy to further modify these equations to suit a differing definition.

 x = r*sin(az).*cos(el);
 y = -r*cos(az).*cos(el);
 z = r*sin(el);
 plot3(x,y,z)

  Of course if you want to see the sphere itself it would be better to use the 'surf' function using the above points along with a mesh which shows the spherical surface.

Roger Stafford

Subject: plotting points in spherical surface

From: Kate

Date: 24 Sep, 2010 03:37:04

Message: 3 of 5

hi,

when i try surf(x, y, z) , i get an error "Z must be a matrix, not a scalar or vector".

any suggestions to help?

thanks again
kate

Subject: plotting points in spherical surface

From: Roger Stafford

Date: 24 Sep, 2010 03:43:06

Message: 4 of 5

"Kate " <chino_tones@hotmail.com> wrote in message <i7h3dd$t55$1@fred.mathworks.com>...
> hi guys,
>
> i have azimuth and elevation values as follows:
>
> [azimuth elevation]= [ 0.2369082089522 1.70518375159222
> -2.90737451551037 1.42445621521504
> -2.97765472371756 1.32636668816057
> -2.9832318553616 1.36219399418402]
>
> i assume distance from center of sphere ,i.e r =5.
>
> how can i plot these 4 points on a sphere?
>
> thanks again
> kate
- - - - - - - - - -
  I just noticed something about one of your elevation numbers. The elevation I defined is intended to range from -pi/2 to +pi/2 radians. However your first elevation figure is 1.70518375159222 which is beyond pi/2. You apparently have a different definition for your elevation values. Perhaps you could tell us what it is?

Roger Stafford

Subject: plotting points in spherical surface

From: Steven_Lord

Date: 24 Sep, 2010 13:56:52

Message: 5 of 5



"Kate " <chino_tones@hotmail.com> wrote in message
news:i7h6d0$9bb$1@fred.mathworks.com...
> hi,
>
> when i try surf(x, y, z) , i get an error "Z must be a matrix, not a
> scalar or vector".

Well, what is it? Is it a scalar, a vector, or a matrix?

> any suggestions to help?

Just the obvious -- if your Z isn't a matrix, make it one. You may find
MESHGRID useful in doing so.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us