Code covered by the BSD License  

Highlights from
Droplet Video Processor - code 3 of 3

image thumbnail

Droplet Video Processor - code 3 of 3

by

 

This code takes the signal generated by parts 1 & 2 and converts it to usable information.

filterTimesByStDev(times)
function times3 = filterTimesByStDev(times)
% this function takes an array, a high and a low bound and eliminates data
% that does not fit inbetween the bound, it returns the shortend array.

    % filter the times array again, by eliminating the outlyers. 
    [tintrval,timeave] = findDiff(times);
    
    % finding the standard deviation
    timeSTDev = std(tintrval);    
    lowerB = (timeave - 2.99*timeSTDev);
    higherB = (timeave + 2.99*timeSTDev);
    clear('timeave','timeSTDev');    
       
    tintrval(1) = NaN;
    for m = 2:size(tintrval,1)
       
        if(tintrval(m) >= lowerB) && (tintrval(m) <= higherB)
        else
           tintrval(m) = NaN;
        end
    end
 
    tintrval = removeNaN(tintrval);
    times3 = NaN([size(tintrval,1),1]);
    times3(1) = times(1);
    v = 2;
    
    for m =1:size(tintrval,1)
        times3(v) = times3(v-1)+ tintrval(m);
        v = v+1;
    end

end


function arrayB = removeNaN(arrayA)
% This function removes all the NaN's from an array and returns the
% shortened array. 

num = 0;
for m = 1:size(arrayA,1) 
    if ~isnan(arrayA(m))
        num = num + 1;
    end
end

arrayB = zeros(num,1);
num = 1;
for m = 1:size(arrayA,1)
    
    if ~isnan(arrayA(m))
        arrayB(num) =  arrayA(m);
        num = num + 1;
    end
end

end


function [arrb,ave] = findDiff(arra)
% This function finds the difference array and average the differences.
    
    arrb = zeros(size(arra,1),1);
    ave = 0; 
    num = 0;
    for m = 1:size(arra,1)  
        
        if m >= 2             
           arrb(m) = arra(m) - arra(m-1);
           ave = ave + arrb(m);
           num = num + 1;
        end  
    end 
    ave = ave/num;
end

Contact us