MATLAB画三维球体函数

MATLAB画三维球体函数区别

共四种方法

[u,v,w] = sphere(56);

subplot(2,2,1)
plot3(u,v,w);
title('plot()')

subplot(2,2,2)
surf(u,v,w)
title('surf')

subplot(2,2,3)
surfl(u,v,w)
title('surfl')

subplot(2,2,4)
mesh(u,v,w)
title('mesh')

运行结果如下:
在这里插入图片描述

画实体球的相关函数

%%
% 三维实心球
t=linspace(0,pi,25);
p=linspace(0,2*pi,25);
[theta,phi]=meshgrid(t,p);
x=sin(theta).*sin(phi);
y=sin(theta).*cos(phi);
z=cos(theta);
[m,n]=size(z);
re=[0 0 1];%改数字 改变颜色、数字为0-1
colormap(re)  % colormap(map) 用map矩阵映射当前图形的色图
surf(x,y,z);
% 是阴影函数控制曲面和图形对象的颜色着色,即用来处理色彩效果的,包括以下三种形式:
% shading faceted:默认模式,在曲面或图形对象上叠加黑色的网格线;
% shading flat:是在shading faceted的基础上去掉图上的网格线;
% shading interp:对曲面或图形对象的颜色着色进行色彩的插值处理,使色彩平滑过渡 ;
shading interp
axis equal;
% daspect([m n p]):将坐标轴的长宽高(x,y,z轴)单位长度之比设为:m:n:p。
% daspect([1 1 1]) = axis equal
daspect([1,1,1])
view(3); 
axis tight % 使得图形框图靠近数据
camlight   % camlight的目的:创建或者移动在camera coordinates里的光源
grid on
lighting gouraud
%%
% colormap的用法
colormap([spring;summer;autumn;winter])%相当于自定义了一个256*3维的colormap  
                                       %实际上spring,summer,autumn,winter
                                       %都是64*3维的colormap
x=[0 1 1 0];
y=[0 0 1 1];                           %定义四个点 [0 0] [1 0] [1 1] [0 1]
fill(x,y,[0 0.1 0.2 0.3]);             %定义四个点的C值    
                                       %则Cmin=0,Cmax=0.3
colorbar;
map=colormap;                          %map为256*3矩阵
  • 12
    点赞
  • 71
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值