
%%Example 2
A=[0.8,0;0,0.64]; 

%%Example 3
%A=[1.44,0;0,1.2]; 

%%Example 4 (Choose low numberOfIterations, maybe 3)
%A=[2,0;0,0.5];

%%Example 5 (Choose low numberOfIterations, maybe 3)
%A=[1.25,-0.75;-0.75,1.25];

%%Example 6
%A=[0.8,0.5;-0.1,1];


numberOfPaths=100;  %Number of random initial points (100 takes a bit of time).
numberOfIterations=7; %Number of the transformation on each path. 

for N=1:numberOfPaths

%Initialization
X=zeros(21,1);
Y=zeros(21,1);
Xchange=zeros(21,1);
Ychange=zeros(21,1);

%Choose random inital point
X(1)=rand()-rand();
Y(1)=rand()-rand();

%Iterate transformation x-->Ax
for k=2:numberOfIterations
    v=A*[X(k-1);Y(k-1)]; 
    X(k)=v(1);
    Y(k)=v(2);
end

%Compute arrows for plot
for k=1:(numberOfIterations-1)
   Xchange(k) = X(k+1)-X(k);
   Ychange(k) = Y(k+1)-Y(k);
end

%Plot arrows
quiver(X,Y,Xchange,Ychange,'off',AutoScale='off',Color='black',LineWidth=1)
axis equal
hold on

end



