Matlab绘制二维圆环和三维圆环

画圆参考:

MATLAB绘图笔记——画圆的几种方法

一、画二维圆环

方法1:利用rectangle函数(不支持透明度)
figure
rectangle('Position',[0,0,5,5],'Curvature',[1,1],'facecolor', [1 0 0], 'edgecolor', 'none');
hold on
rectangle('Position',[1,1,3,3],'Curvature',[1,1],'facecolor', [1 1 1], 'edgecolor', 'none');
axis equal
axis off

在这里插入图片描述

方法2:利用patch函数(支持透明度)
figure
t = 0 : .1 : 2 * pi;
x2 = 2.5 * cos(t);
y2 = 2.5 * sin(t);
cmap = [1,0,0];
patch(x2, y2, cmap, 'facealpha', 0.4, 'edgecolor', 'none'); %// plot filled circle with transparency  
hold on
x3 = 1.5 * cos(t);
y3 = 1.5 * sin(t);
cmap = [1,1,1];
patch(x3, y3, cmap, 'facealpha', 1, 'edgecolor', 'none'); %// plot filled circle with transparency  
axis equal
axis off

在这里插入图片描述

二、画三维圆环

figure
r = linspace(0,2*pi,60);
s = linspace(0,pi,60);
[u,v] = meshgrid(r,s);
x = 2*(8+cos(v)).*cos(u);
y = 2*(8+cos(v)).*sin(u);
z = 2*2*sin(v);
mesh(x,y,z);
colormap
axis equal
axis off

在这里插入图片描述

补充

figure
t = 0 : .1 : 2 * pi;
x1 = 2.5 * cos(t);
y1 = 2.5 * sin(t);
x_1 = [x1(1:21);x1(22:42);x1(43:end)]';
y_1 = [y1(1:21);y1(22:42);y1(43:end)]';
cmap = hsv(21);
patch(x_1, y_1, cmap, 'facealpha', 1, 'edgecolor', 'none'); %// plot filled circle with transparency
axis equal
axis off

在这里插入图片描述

  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值