function fcn1(h)
persistent tri rect
      % P1  P2     P3   P4  P1
xvec = [0, h(1), 2-h(1), 2, 0];
yvec = [0, h(1),   h(1), 0, 0];
plot([0 1 2 0], [0, 1, 0, 0], 'k', 'LineWidth', 3);
hold on
tri = fill(xvec, yvec, 'k');
rect = fill([1.5 1.5 2 2 1.5], [1.5 2 2 1.5 1.5], 'b');
hold off
rect.Visible = 'off';
axis([-0.5 2.5 0 2.5]);
for k = 1:numel(h)
    tri.XData = [0, h(k), 2-h(k), 2, 0];
    tri.YData = [0, h(k),   h(k), 0, 0];
    if h(k) > 0.7
        rect.Visible = 'on';
    else
        rect.Visible = 'off';
    end
    pause(0.2)
end
end
