name='ready_PFTSs.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;
    
  
nb=502;
ne=1000;
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=0;
for i=1:col
if R(i,i)==1 c=c+1; matr=[matr i];
end
end
f=fopen(strcat('ready_',name),'wt');
fprintf(f,'%i',c);
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==n
            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(f);
