Plot a rectangle inside of a rectangle.

4 vues (au cours des 30 derniers jours)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA le 1 Fév 2022
How can I plot a rectangle inside of a rectangle. I have a rectangle of 50 width and 20 length. I need a rectangle inside with 15 width and 10 length. How to code it? I need matlab code or suggations for this.

Réponse acceptée

Image Analyst
Image Analyst le 2 Fév 2022
Have you tried the rectangle function?
rectangle('Position', [5,2,50,20], 'EdgeColor', 'r', 'LineWidth', 2);
hold on;
rectangle('Position', [15,5,15,10], 'EdgeColor', 'b', 'LineWidth', 2);
grid on;
axis equal
Adjust numbers to get the placement you want.
  1 commentaire
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA le 2 Fév 2022
Thnaks. Worked pretty well.

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 1 Fév 2022
Modifié(e) : Matt J le 1 Fév 2022
One way,
V=[-1 -1;
+1 -1;
+1 +1 ;
-1 +1]/2;
p=[polyshape(V.*[50,20]), polyshape(V.*[15,10])];
plot(p)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by