function wiggle(X)

%*****************************************************************************80
%
%% wiggle() performs dynamic matrix multiplication.
%
%  Discussion:
%
%    wiggle(X) wiggles the 2-by-n matrix X.
%
%    wiggle(house)
%    wiggle(hand)
%
%  Licensing:
%
%    Copyright 2014 The MathWorks, Inc.
%
%  Author:
%
%    Cleve Moler
%
%  Reference:
%
%    Cleve Moler,
%    Experiments with MATLAB
%    https://www.mathworks.com/moler
%
set(gcf,'menubar','none','numbertitle','off','name','Wiggle')
if nargin < 1
   X = house;
end

thetamax = 0.1;
delta = .025;
t = 0;
stop = uicontrol('string','stop','style','toggle');
while ~get(stop,'value')
   theta = (4*abs(t-round(t))-1) * thetamax;
   G = [cos(theta) sin(theta); -sin(theta) cos(theta)];
   Y = G*X;
   dot2dot(Y);
   drawnow
   t = t + delta;
end
set(stop,'string','close','value',0,'callback','close(gcf)')
