MATLAB-基于不平等的3D体积填充
我有三个变量x
,y
和z
。我的形式不平等
x> = a,y> = b,z> = c,x+y> = d,y+z> = e,= e,x+z> = f,x> = f,x+y+ z> = g
其中a
to g
是正数。在带有轴x
的3D图上,y
和z
,这是一个打开的卷。我想用颜色填充开放的侧面(即远离0)形状,并在图中显示。在MATLAB上执行此操作的方法是什么?
我尝试使用fill3
和网格,但是使用plot3
也不是很好,结果
[x,y,z] = meshgrid(0:0.01:2,0:0.01:2,0:0.01:2);
ineq = (x>=1)& (y>0.5)&(z>=0.25)&(x+y>1.25)&(y+z>0.6)&(x+z>1.1)&(x+y+z>1.6);
fill3(x(:),y(:),z(:), 'r')
box on
grid on
也不是很好。还有其他方法可以在MATLAB上生成漂亮的3D数字吗?
Mathematica使用regionPlot3D来做到这一点。我希望有类似的结果图像。
I have three variables x
, y
and z
. I have inequalities of the form
x >= a, y>= b, z>=c, x+y>=d, y+z>=e, x+z>=f, x+y+z>=g
where a
to g
are positive numbers. On a 3D plot with axes x
, y
and z
, this is an open volume. I would like to fill the open side (i.e. away from 0) shape with color and show it in a plot. What is the way to do this on MATLAB?
I attempted to use fill3
and a mesh but the result was not very good
[x,y,z] = meshgrid(0:0.01:2,0:0.01:2,0:0.01:2);
ineq = (x>=1)& (y>0.5)&(z>=0.25)&(x+y>1.25)&(y+z>0.6)&(x+z>1.1)&(x+y+z>1.6);
fill3(x(:),y(:),z(:), 'r')
box on
grid on
Using plot3
also was not very good. Is there any other way to generate a nice 3D figure on MATLAB?
Mathematica does this using RegionPlot3D. I was hoping for a similar resultant image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,使用3D网格时要小心,您定义的一个包含8m+点。
假设您的形状为凸,您可以使用 href =“ https://www.mathworks.com/help/matlab/ref/ref/trisurf.html” rel =“ nofollow noreferrer”> trisurf :
不是选项
设置为真实,以减少凸船体中所述的元素数量。
如果您希望结果看起来比regionplot3d多一点,请不要使用
简化
,然后绘制边缘(请小心不要与太多点的网格!)。First of all, be careful when using 3D meshes, the one you defined contains 8M+ points.
Assuming your shape is convex, you can use convhull and trisurf:
Not that the option
'Simplify'
is set as true to reduce the number of elements accounted for in the convex hull.In case you want the result to look a bit more than RegionPlot3D, don't use
Simplify
, and plot the edges (Be careful not too have a mesh with too many points!).