how to plot geometric figures?

Dear sir/madam,
I am working on geometric shapes. I need to plot geometric shapes like square, rectangle, triangle etc... in matlab. How could I do this in matlab? Looking forward to hearing from you soon.
Thanking you, BSD

 Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Ag. de 2011

0 votos

Consider also patch()
rectangle() can be used to plot squares, rectangles, ellipses, and circles.

Más respuestas (4)

Honglei Chen
Honglei Chen el 29 de Ag. de 2011

0 votos

You can just give the coordinates for each vertex, e.g., for square
plot([0 1 1 0 0],[0 0 1 1 0])
If you don't want the axes, you can do
axis off
If you want to be fancy, you can wrap the above code in a function and take the width as the input and then calculate the vertex coordinates inside the function.
HTH
Florin Neacsu
Florin Neacsu el 29 de Ag. de 2011

0 votos

Hello,
You might want to have a look at geom2d on the file exchange.
Regards, Florin
ali cherif abdelkader
ali cherif abdelkader el 17 de Feb. de 2018

0 votos

hello brother, you can use GeoGebra app and copy the coordinate of your shape from GeoGebra to matlab one by one.

1 comentario

Badriah Al-Juaid
Badriah Al-Juaid el 27 de Oct. de 2019
hi , could you please explain GeoGebra / what is it ?

Iniciar sesión para comentar.

Steven Lord
Steven Lord el 17 de Feb. de 2018

0 votos

If you're using release R2017b or later, use the polyshape function.

Etiquetas

Preguntada:

bsd
el 29 de Ag. de 2011

Comentada:

el 27 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by