MATLAB: Drawing a trapezium in matlab

trapezium

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.

Best Answer

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