How to draw a square with specific plot points
Ältere Kommentare anzeigen
I'm trying to create two squares, one larger one, and the other within it.
I attempted to create one using matrices. I create one with x = [0 0 1 1] and y = [0 1 1 0]
I wanted a line to connect each one of the points, to thus create a line. However, when I did that, I only received three lines connect between the dots for some reason. The bottom points (0,0) and (1,0) for some reason were not connected. I then attempted to make a second square, and the same thing happened, with the two lower points in regards to their Y points did not connect. I tried using the rectangle function as well, but can't get a square within a square to appear. Any help would be great. Thanks
Akzeptierte Antwort
Weitere Antworten (4)
Camilo Malagon Nieto
am 8 Mai 2019
1 Stimme
Worth to say that there is a function now to make a rectangle and smooth the corners.
Cheers,
1 Kommentar
Tamar Hoory
am 2 Jun. 2022
thanks for the useful answer!
x = [0 0 1 1];
y = [0 1 1 0];
P1 = polyshape(x, y);
plot(P1)
axis square
P2 = translate(scale(P1, 0.5), [0.25 0.25]);
figure
plot([P1, P2])
axis square
NAGENDRA KUMAR
am 12 Sep. 2017
Verschoben: Image Analyst
am 29 Jul. 2024
Please write this code
x = [0 0 1 1 0];
y = [0 1 1 0 0];
plot(x,y,'r', 'LineWidth',3)
Pranav
am 29 Jul. 2024
0 Stimmen
The IMAGE ANALYST did a great job at answering this question.
2 Kommentare
Image Analyst
am 29 Jul. 2024
Thanks! 🙂
Pranav
am 29 Jul. 2024
Anytime, Keep up the great work!!!
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



