- Thread starter
- #1

#### CaptainBlack

##### Well-known member

- Jan 26, 2012

- 890

The following is FreeMat code, but it should get you close enough in pure Matlab: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.

Code:

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

Last edited: