%example 1. An affine  fractal interpolation function
%Give the interpolation points
clear;
N=2;
IP=[0.00  12;
    0.60  10;
    1.00  11];
S=[-0.4 0.7];
steps=6;
P=myFIF2(IP,S,N,steps,IP);
hold on;
plot(IP(:,1),IP(:,2),'red');
plot(P(:,1),P(:,2));




%example2. Amother affine FIF
clear;
N=2;
IP=[0.00  10;
    0.5   13;
    1.00  11];
S=[0.5 0.7];
steps=10;
P=myFIF(IP,S,N,steps);
plot(P(:,1),P(:,2));
hold on;
plot([IP(1,1) IP(N+1,1)],[IP(1,2) IP(N+1,2)],'red');



%example 3. Another affine FIF
clear;
N=5;
IP=[0.0  9;
    0.2  11;
    0.4  15;
    0.6  8;
    0.8  12
    1.0  10];

%contraction factors
S=[-0.2 -0.6 0.3 0.5 0.3];
steps=5;
P=myFIF(IP,S,N,steps);
plot(P(:,1),P(:,2));
D=1+log(sum(abs(S)))/log(N);





%example 4. An affine Recurrent FIF

clear;
N=4;
IP=[0.00   9;
    0.25   11;
    0.50   10;
    0.75   11;
    1.00   9.5];
%contraction factors
S=[ 0.5 -0.6  -0.4  0.6];
steps=8;
%RFIF
AD=[0.00 0.50 9 10;
    0.50 1.00 10 8;
    0.50 1.00 10 8;
    0.00 0.50 9 10];

P=myRFIF(IP,AD,S,N,steps);
plot(IP(:,1),IP(:,2),'red');
hold on;
plot(P(:,1),P(:,2));
hold off;
%dimension:
S_=abs(diag(S));
alpha=2;
C=[1 1 0 0; 0 0 1 1; 0 0 1 1; 1 1 0 0];
el=max(abs(eig(S_*C)));
D=1+log(el)/log(alpha);







%Example 5. A RFIF

clear;
N=5;
IP=[0.00   11;
    0.20   9;
    0.50   10;
    0.70   12;
    0.85   10.5;
    1.00   10];

%contraction factors
S=[ 0.5 -0.6 0.5 -0.6 0.7 ];
steps=13;

%RFIF
AD=[0.70 1.00 12 10;
    0.00 0.50 11 10;
    0.70 1.00 12 10;
    0.20 0.70 9 12;
    0.20 0.70 9 12;
    ];

P=myRFIF(IP,AD,S,N,steps);
plot(P(:,1),P(:,2));
hold on;
plot(IP(:,1),IP(:,2),'red');
hold off;



