name='ready_PFTS2.txt';
%a=transpose(a);
fd=fopen(name);
    col=fscanf(fd,'%d',1);
    res.col=col;
    n=fscanf(fd,'%d',1);
    res.dnei=n;
    a=[];
    for j=1:col
        b=fscanf(fd,'%e',n);
        a=[a;transpose(b)];
    end
    a=transpose(a);
    res.matr=a;
    str=[];
    for i=1:col
        b=fscanf(fd,'%s',1);
        str(i).name=b;
        %disp(b);
    end
    for i=1:col
        b=fscanf(fd,'%i',1);
        str(i).type=b;
        str(i).color=[0 0 0]; 
    end
    res.str=str;
    fclose(fd);
    calaz=[];
    fd=fopen('colors.ini');
    if fd~=-1
        n=fscanf(fd,'%e',1);
        for i=1:n
            li=fscanf(fd,'%e',4);
            calaz=[calaz;transpose(li)];
            %disp(calaz);
        end
        for i=1:col
            for j=1:n
                if calaz(j,1)==res.str(i).type
                    res.str(i).color=[calaz(j,2) calaz(j,3) calaz(j,4)];
                    %disp(res.str(i).color);
                end
            end
        end
        f=0;
    else
        f=-1;
    end

  
nb=2;
ne=500;
a=res.matr;
str=res.str;
logm=zeros(ne-nb+1,col);
for j=1:col
    for i=nb:ne
        logm(i-nb+1,j)=log(a(i,j))-log(a(i-1,j));
    end
end
%for j=1:col
 %   for i=nb:ne-1
 %       logm(i-nb+1,j)=-log(a(i,j))+log(a(i+1,j));
 %   end
 %end
 R=[];
R=corrcoef(logm);
matr=[];
c=[];
for i=1:269
if R(i,i)==1 c=c+1;matr=[matr i];
end
end
f=fopen(strcat('ready_',name),'wt');
fprintf(f,'%i',col);
fprintf(f,'%s',' ');
fprintf(f,'%i',n);
fprintf(f,'\n');
a=transpose(a);
for i=1:size(matr,2)
      for j=1:n
        fprintf(f,'%e',a(matr(i),j));
        if j==l
            fprintf(f,'\n');
        else
            fprintf(f,'%s',' ');
        end
    end
end
fprintf(f,'\n');
for i=1:size(matr,2)
    fprintf(f,'%s',str(matr(i)).name);
    fprintf(f,'\n');
end
for i=1:size(matr,2)
    fprintf(f,'%i',str(matr(i)).type);
    fprintf(f,'\n');
end
fclose
