clear all;
clc;

x=[0.144 0.287 0.431 0.574 0.718 0.861 1.005 1.148 1.292 1.435];   %prud [A]
y=[2 4 6 8 10 12];                                                %vychylka [mm]

%sila [N]
z= [3.0 1.2 0.7 0.5 0.4 0.3
    11.9 4.7 2.8 2.0 1.5 1.2
    26.8 10.6 6.3 4.5 3.4 2.8
    47.6 18.9 11.3 7.9 6.1 4.9
    74.4 29.5 17.6 12.4 9.5 7.7
    107.1 42.5 25.4 17.8 13.7 11.0
    145.8 57.8 34.5 24.3 18.6 15.0
    190.5 75.5 45.1 31.7 24.3 19.6
    241.0 95.6 57.0 40.1 30.7 24.8
    297.6 118.0 70.4 49.5 37.9 30.7
    ];


nx=size(x,2);
ny=size(y,2);
n=5;                %stupen polynomu
na=(n+2)*(n+1)/2;   %poèet koeficientov  
II=0;
max=max(nx,ny);
A=zeros(max);

for k=0:1:n;
    for l=0:1:k;
        II=II+1;
        JJ=0;
        for kk=0:1:n;
            for ll=0:1:kk;
                JJ=JJ+1;
                s=0;
                for i=1:1:nx
                    for j=1:1:ny
                        s=s+(x(i)^(kk-ll+k-l))*(y(j)^(ll+l));
                    end
                end
                A(II,JJ)=s;
            end
        end
    end
end

B=zeros(size(A,2),1);

II=0;
for k=0:1:n;
    for l=0:1:k;
        II=II+1;
        s=0;
        for i=1:1:nx
            for j=1:1:ny;
                s=s+z(i,j)*(x(i)^(k-l))*(y(j)^l);
            end
        end
        B(II,1)=s;
    end
end

 %hodnosti matic

 h1=rank(A)
 h2=rank([A B])
 
 %vysledky
 a=A\B

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    