Drawing a trapezium in matlab

46 次查看(过去 30 天)
Is there a quick way, apart from using vertices, to draw an isosceles trapezium given the height and the length of both parallel sides? Thank you.

采纳的回答

KSSV
KSSV 2018-2-23
编辑:KSSV 2018-2-23
h = 1 ; % height
a = 2 ; % top side
b = 4 ; % base
%%Frame vertices
A = [0 0] ;
B = [b 0] ;
C = [0.5*(b-a)+a h] ;
D = [0.5*(b-a) h] ;
coor = [A ; B; C; D] ;
patch(coor(:,1), coor(:,2),'r')
Refer here how the coordinates are formed: http://mathworld.wolfram.com/IsoscelesTrapezoid.html
  4 个评论
DGM
DGM 2023-8-17
See patch().
The argument list are x-coordinates, y-coordinates, and the line color.
A,B,C,D are [x y] pairs. They're simply concatenated to form the 4x2 matrix coor, from which the x,y vectors are taken in the call to patch().

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by