%
%  rainflow_numerical_engine_alt_np.m  ver 1.0  by Tom Irvine
%

function[amp_cycles,amp_mean_cycles,range_cycles_max_min,range_cycles,BIG]=...
                                                 rainflow_numerical_engine_alt_np(y)   
                                             
     y=double(y); 


     [c,~,~,~,~] = rainflow(y);

     
     B(:,1)=c(:,2); 
     B(:,2)=c(:,1);
     
     nn=length(c(:,1));
     
     for i=1:nn
        B(i,3)=y(c(i,4));
        B(i,4)=y(c(i,5));      
     end   
        
     aamax=max(c(:,2));


    [BIG,C,range_cycles,amean,amp_max,amp_min]=bin_sorting_alt(B,aamax);
   
    
    amp_cycles=[range_cycles(:,1)/2 range_cycles(:,2)];
    amean=fix_size(amean);
    amp_mean_cycles=[range_cycles(:,1)/2 amean range_cycles(:,2)];
 
    amax=fix_size(amp_max);
    amin=fix_size(amp_min);
    
    range_cycles_max_min=[range_cycles(:,1) range_cycles(:,2) amax amin ];