MATLAB: Generate coordinates circle,square,rectangle

generate matrixMATLABpoints

Hello,
I have to generate points(matrix),so that i have view the points as a circle(square,rectagle), when i display points(matrix) through plot.
Could someone help me?
Thanks.

Best Answer

For circle and ellipse, see the FAQ for code examples: http://matlab.wikia.com/wiki/FAQ?title=FAQ&cb=7341#How_do_I_create_a_circle.3F
For a square or rectangle, if you have x1, x2, y1, and y2, you can make it with plot by making coordinates of the box and calling plot
xBox = [x1 x2 x2 x1 x1];
yBox = [y1 y1 y2 y2 y1];
plot(xBox, yBox, 'r-', 'LineWidth', 2);
Of course that can ge generalized to any polygon, just list all the vertices.