Just like one of Matlab's function: SURF/SURFACE. The function creates a surface based on a matrix or columns(x,y, and/or z). Reading Matlab's help on surf bewildered me further. My intention was simple. I wanted to create a surface, but i didn't have a z function and my z was not anyhow defined by x and y. If my z is well defined, i might as well have a pretty good model for what i am trying to do.

Anyway, imagine that you just want to create a square plane. How do you do it with surf ?

After fiddling with this and that, reading this and that, i finally realized what needs to be understood.

Say, i want to create a 2 x 2 plane flattened on z = 2 using coordinates.

As unintelligent as this might look, i could actually go by doing the followings:

> x = [-1 1; -1 1]; > y = [-1 -1; 1 1]; > z = [ 2 2; 2 2];

> surf(x,y,z);

For a smart person like you, you should already recognize the that there are 4 x-y-z points (-1 -1 2), (1 -1 2), (-1 1 2), and (1 1 2). Note that even you know z is 2 across the whole plane. You cannot just input 2. You need a MxN matrix (which happens to be the M and N of X or Y), which makes sense other wise, Matlab won't know how to reconstruct that plane. In the above case, it will be a 2 x 2 matrix. This might seem introductory to you. But it gives me a better understanding of making a surface in matlab.

## No comments:

## Post a Comment