# Godelproof Matlab 3D Plot question

#### CaptainBlack

##### Well-known member
godelproof said:
I want to draw this surface on $$[0,1]^3$$:

$$z=x$$ for $$x\geq y$$ and $$z=y$$ for $$y>x$$
I know "meshgrid" coupled with "surface" command allows you to draw $$z=x$$ and $$z=y$$, respectively. But I have no idea how to account for the inequalities.
Thanks.
The following is FreeMat code, but it should get you close enough in pure Matlab:

Code:
--> x=[0:0.1:1];
--> [X,Y]=meshgrid(x);
--> Z=X.*(X>=Y)+Y.*(X<Y);
--> surf(X,Y,Z);
CB

Last edited: