4 May 2017

draw rectangle, polygon and circle in Matlab

To draw these shapes in Matlab, different ways could be used to achieve this. Write your own function to use plot(), or use rectangle() or use patch().

The rectangle() can be used to draw ellipse, circle, round-corner rectangle as well if you specify the 'Curvature' parameter.

The plot() and patch() uses the same input as (x,y) list, which means x, and y are vectors of corresponding coordinates. You can use these two function draw polygons with any number of points.

rectangle() uses input as [x,y,w,h] rather than (x,y) list. rectangle() can only accept input as a 4 elements vector. It requires calling of daspect([1,1,1]) to make the equality along each axis. However, it is very handy if you are drawing proper rectangle and circle.

1 comment :

  1. Great and really helpful article! Adding to the conversation, providing more information, or expressing a new point of view...Nice information and updates. Really i like it and everyday am visiting your site..
    Office Interiors in Chennai
    Interior Decorators in Chennai