% % triangle.m Demonstrating the loop and % graphics interaction % h=figure; set(gcf,'DefaultTextColor','red'); v=get(h); c=[0 100 100 0 0]; d=[0 0 100 100 0]; plot(c,d, 'g-'); title('First loop test'); a=10; b=20; len=80; % length x(1)=a; x(2)=x(1)+len; x(3)=x(2)-len/2.; x(4)=x(1); %-------------------- y(1)=b; y(2)=y(1); y(3)=y(2)+len*sin(pi/3); y(4)=y(1); % line([x(1) x(2)],[y(1) y(2)]); text(x(1),y(1),num2str(1)); % line([x(2) x(3)],[y(2) y(3)]); text(x(2),y(2),num2str(2)); line([x(3) x(4)],[y(3) y(4)]); text(x(3),y(3),num2str(3));