简体   繁体   中英

matlab - plot inequality in 3d with surf

I want to plot an inequality in 3d using surf . My condition is

0<=x<=1    
0<=y<=1    
0<=z<=x/(1+y)

I can create a surface plot using the following commands

[x y]=meshgrid(0:0.01:1);    
z=x./(1+y);    
surf(x,y,z);

This plot gives me regions where z=x/(1+y) but I am interested in regions where 0<=z<=x/(1+y) over all values of x and y . However, I am unable to plot/color the region explicitly. Can you please help.

A similar question has been asked but there was no acceptable answer and my question is also different.

Using isosurface you can show the boundary. There are two options, first create the points

[X,Y,Z]=meshgrid(0:.01:1);

then plot the boundaries in the z -direction (ie Z=0 and Z=X./(1+Y) )

isosurface(X,Y,Z,Z.*(X./(1+Y)-Z),0)

or plot all the boundaries (including X=0 , X=1 , Y=0 and Y=1 )

isosurface(X,Y,Z,Z.*(X./(1+Y)-Z).*X.*(X-1).*Y.*(Y-1),0)

All you have to do is come up with a function that is constant on any boundary, its value inside or outside is irrelevant as long as it is not zero.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM