Creating a rectangle with 4 points
Mostrar comentarios más antiguos
Hello, I have 4 points with (x,y,z) and I want to have a closed shape which connects them.
I actually want to draw 4 lines between the 4 points and make them a rectangle.
Thank you for help.
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 1 de Mayo de 2020
Did you try rectangle()?
rectangle('Position', [x1, y1, x2-x1, y2-y1], 'FaceColor', 'r', 'EdgeColor', 'k');
or using line():
line([x1,x2], [y1, y1], 'Color', 'r', 'LineWidth', 2);
hold on;
line([x1,x2], [y2, y2], 'Color', 'r', 'LineWidth', 2);
line([x1,x1], [y1, y2], 'Color', 'r', 'LineWidth', 2);
line([x2,x2], [y1, y2], 'Color', 'r', 'LineWidth', 2);
hold off;
1 comentario
Umut Ege Ulucay
el 2 de Mayo de 2020
Categorías
Más información sobre Polygons en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!