Plot sphere with different resolution in long and lat direction

2 次查看(过去 30 天)
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!

采纳的回答

David Goodmanson
David Goodmanson 2017-10-20
编辑:David Goodmanson 2017-10-20
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)

更多回答(0 个)

类别

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