C-Star Tranmsittance/c MATLAB Implementation

function [Tr, c] = compute_transmittance ( Vsig, Vdark, Vref, path_length  )
% COMPUTE_TRANSMITTANCE:  calculate light transmittance products from raw engineering units
%
% USAGE:  [Tr, c] = compute_transmittance ( Vsig, Vdark, Vref, path_length );
%
% PARAMETERS:
% Input:
%    Vsig:
%        the measured analog signal
%    Vdark:
%        the factory-supplied dark voltage offset for the instrument.  
%    Vref:
%        the factory-supplied clean water offset
%    path_length:
%        
%
% Output:
%    Tr:  
%        transmittance.  Range 0 to 100 percent.
%    c:
%        attenuation coefficient.  Units m-1


Tr = (Vsig - Vdark) / (Vref - Vdark);
c = -1 * log ( Tr ) ./ path_length;

%
% Convert to percent.
Tr = Tr*100;

return;