Plot sphere with different resolution in long and lat direction

3 views (last 30 days)
Hi everybody,
I would like to modify MATLAB's
sphere(n)
function such that I can plot a sphere with different resolution in longitudinal and latitudinal direction, i.e. something like
sphere(10,100)
would plot a sphere (and return its [X,Y,Z] grid) with 10 segments in latitudinal direction (north to south) and 100 segments in longitudinal direction (west to east), evenly spaced. What's the quickest way to doing this?
Thanks a lot!

Accepted Answer

David Goodmanson
David Goodmanson on 20 Oct 2017
Edited: David Goodmanson on 20 Oct 2017
Hi Peter,
There is really not the kind of limitation on surf that you seem to imply. This example shows a sphere with different number of points for latitude and longitude.
m = 10; % latitude
n = 25; % longitude
theta = ((-m/2:m/2)/m)*180; % degrees
phi = ((0:n)/n)*360; % degrees
[theta1 phi1] = meshgrid(theta,phi);
x = cosd(theta1).*cosd(phi1);
y = cosd(theta1).*sind(phi1);
z = sind(theta1);
surf(x,y,z)

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!