Making Triangle in matlab

6 vues (au cours des 30 derniers jours)
Wahab Ahmad
Wahab Ahmad le 30 Avr 2020
How do I make the triangle without plotting function like that?

Réponses (2)

KSSV
KSSV le 30 Avr 2020
m = 100;
n = 2*m;
I = zeros(m,n) ;
for i = 1:m-1
idx = (n/2-i):(n/2+i) ;
I(i,idx)= 1 ;
end
imshow(I)
  5 commentaires
Wahab Ahmad
Wahab Ahmad le 30 Avr 2020
That code is not works
KSSV
KSSV le 30 Avr 2020
Why it not work? You have to change vertices accordingly.

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 18 Juil 2022
You can use poly2mask
x = [100, 200, 300]; % Left vertex, top vertex, right vertex.
y = [300, 100, 300]; % Left vertex, top vertex, right vertex.
mask = poly2mask(x, y, 400, 400);
imshow(mask);
axis on

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by