%This function plots the attractor of a specific RIFS of R^2,
%using the Random Iteration Algorithm.
%Input: A0, W, P, N, K, first_map
%A0 is the initial point represented by a 1x2 matrix
%P is the matrix NxN containing the probabilities
%N is the number of the mappings
%K is the number of iterations
%W is the matrix Nx6 containing the parameters of the mappings
%first map is the number of the first map w_i, that it is applied to A0
%Each row (i) contains the 6 coefficients of the map w_i. a,b,c,s,d,e
% / \ / \
% |a b| | d |
%w=| | + | |
% |c s| | e |
% \ / \ /
%The function plots the attractor!!!
%Therefore, you may want to open a new figure.
%Output: nothing
function B=MYRRIA_R2(A0,W,P,N,K,first_map)
figure(1);
hold on;
for i=1:N
SP(i,1)=P(i,1);
for j=2:N
SP(i,j)=SP(i,j-1)+P(i,j);
end;
end;
X=A0(1,1);
Y=A0(1,2);
plot(X, Y , 'b.' , 'MarkerSize' , 2);
r=first_map;
for (i=1:K)
nX=W(r,1)*X+W(r,2)*Y+W(r,5);
nY=W(r,3)*X+W(r,4)*Y+W(r,6);
X=nX;
Y=nY
plot(X, Y , 'b.' , 'MarkerSize' , 2);
what=rand(1);
for j=1:N
if what