matlab画半球

%Hemisphere
clear,clc,close all
%Sphere radius
R=1; 
%Set grid number
n=30; 
theta = (-n:2:n)/n*pi;
phi = ([0,0:2:n])'/n*pi/2;
cosphi = cos(phi); cosphi(1) = 0; cosphi(end) = 0;
sintheta = sin(theta); sintheta(1) = 0; sintheta(end) = 0;
x = R*cosphi*cos(theta);
y = R*cosphi*sintheta;
z = R*sin(phi)*ones(1,n+1);
%The figure color is beach color
colormap([0.77 0.61 0.4]);
surf(x,y,z);
%Set title, etc
title('Hemisphere');
set(gca,'xticklabel',[])
set(gca,'yticklabel',[])
set(gca,'zticklabel',[])

发布了13 篇原创文章 · 获赞 15 · 访问量 1296

猜你喜欢

转载自blog.csdn.net/qq_43625266/article/details/104832202