understanding the syntax in the surface command

1 view (last 30 days)
The simple form of the surface cammand is straightforward to understand:
surface(x,y,z)
where x,y,z are vectors.
However, I find it difficult to understand when x, y and z are matrices. As in the following commands :
% front
surface([-1 1; -1 1], [-1 -1; -1 -1], [-1 -1; 1 1],'FaceColor', 'texturemap', 'CData', t1 );
% top
surface([-1 1; -1 1], [-1 -1; 1 1], [1 1; 1 1],'FaceColor', 'texturemap', 'CData', s1);
view(3)
% t1 and s1 are just any two images that can be texture mapped on to cube surfaces
I would appreciate it if somebody could explain to me how the syntax works in the above commands. What is the best way of understanding these commands, where x, y and z are matrices? Thanks

Answers (1)

Ravi
Ravi on 25 Jul 2013
I have the solution now. Just required a little more effort on my part. Thought that I should share it.
When we have x, y and z as matrix arguments as in the following, just gather all the indices together to get the 3D coordinates of a point.
% front
surface([-1 1; -1 1], [-1 -1; -1 -1], [-1 -1; 1 1],'FaceColor', 'texturemap', 'CData', t1 )
The x, y and z matrices above are equivalent to (front face of a cube) :
[(-1,-1,-1) (1,-1,-1); (-1,-1,1) (1,-1,1)]
Similiarly, the top face becomes :
[(-1,-1,1) (1,-1,1); (-1,1,1) (1,1,1)]
Ridiculously simple. I should have arrived at this a lot sooner.
Ravi

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!