Reputation: 13
i'd like to draw sphere using 'patch' function in Matlab.
in function 'patch' "vertex=[~~]" in this part, how to choice the point...
And i wonder if possible to draw sphere using 'patch function'..
please help!
Upvotes: 1
Views: 1116
Reputation: 5157
Assume you have coordinates for points on the sphere in x
, y
, and z
, as obtained by
[x,y,z] = sphere;
Then faces and vertices of a patch object can be obtained using surf2patch:
fvc = surf2patch(x,y,z);
Finally, it can be plotted:
patch('Faces', fvc.faces, 'Vertices', fvc.vertices, 'FaceColor', [1, 0, 0])
This approach can be generalized to any function data.
Upvotes: 3