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.

calcFreqDia(data, Flow)
function [data] = calcFreqDia(data, Flow)
% This function calculates the diameters AND the frequency of the droplet given the time and
% water flow data, it returns S, the sturct with the diameters filled in. 

    dia = 0;
    Array = data.seconds;
    
    diameters = NaN(size(Array,1),1);
    freq = NaN(size(Array,1),1);
          
    freqSum = 0;
    diaSum = 0;
    diaErrorSum = 0;
    FreqErrorSum = 0;
   % Calculate the diameter of the droplets from the time & Flow Rate    
   for m = 1:size(Array,1)
        
       if m >= 2
           if ~isnan(Array(m))
              freq(m) = Array(m) - Array(m-1);
                               
              diameters(m) = findDiameter(freq(m), Flow);
              diahigh = findDiameter((freq(m)+0.04),(Flow+0.05));
              dialow = findDiameter((freq(m)-0.04),(Flow-0.05));
              
              diaErrorSum = diaErrorSum + (abs(diahigh - dialow)/2);
              FreqErrorSum = FreqErrorSum+(abs((freq(m)-0.04)-(freq(m)+0.04))/2);
              diaSum = diameters(m) + diaSum;
              freqSum = freq(m) + freqSum;
              
           end
       end      
   end
   
   freqSum = freqSum/(size(Array,1)-1);
   diaSum = diaSum/(size(Array,1)-1);
   diaErrorSum = diaErrorSum/(size(Array,1)-1);
   FreqErrorSum = FreqErrorSum/(size(Array,1)-1);
   
   data.diameters = diameters;
   data.frequency = freq;
   data.AveDiameter = diaSum;
   data.Avefrequency = freqSum;
   

   
   data.FreqSTDev = findStdev(data.frequency, freqSum);
   data.DiaSTDev = findStdev(data.diameters, diaSum);
   data.DiaError = diaErrorSum;
   data.FrequencyError = FreqErrorSum;
   
end


function val = findStdev(Array2, ave)
% Finding the Standard Deviation
StdValues = zeros(size(Array2,1),1);

  for m = 1:size(Array2,1)
       if ~isnan(Array2(m))
          StdValues(m) = (ave - Array2(m))^2;   
       end
  end
     
    val = mean(StdValues);
    val = sqrt(val);
end



function dia = findDiameter(Freq, Flow2)
% This function figures the droplet Dimeter in microns based on the flow
% rate and the frequency you pass it. 

    dia = Flow2 *(1/3600)*(1/1000000)*(Freq);
    dia = ((3*dia)/(4*pi))^(1/3);
    dia = dia*2*1000000;

end

Contact us