1

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.

Community
  • 1
  • 1
Shehroz
  • 347
  • 2
  • 9
  • 25

1 Answers1

3

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 (i.e. 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.

David
  • 8,449
  • 1
  • 22
  • 32