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=[12 10 8 6 4 2];                                                 %vychylka [mm]
 
%indukènos� [mH]
z1=[6.3 6.3 6.3 6.3 6.3 6.3 6.3 6.3 6.3 6.3 
    7.7 7.7 7.7 7.7 7.7 7.7 7.7 7.7 7.7 7.7
    9.8 9.8 9.8 9.8 9.8 9.8 9.8 9.8 9.8 9.8 
    12.9 12.9 12.9 12.9 12.9 12.9 12.9 12.9 12.9 12.9 
    18.8 18.8 18.8 18.8 18.8 18.8 18.8 18.8 18.8 18.8 
    34.0 34.0 34.0 34.0 34.0 34.0 34.0 34.0 34.0 34.0 
   ];

z=transpose(z1);

nx=size(x,2);
ny=size(y,2);
n=4;                %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
   
    
   

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    