function T = thermistorT(r)
% thermistorT  Temperature of YSI model 44006 thermistor as function of resistance.
%
% Synopsis:  T = thermistorT(r)
%
% Input:  R = resistance in ohms
%
% Output:  T = temperature in C
%
% Note:  Curve fit T = f(r)  (T in C, r in ohms) is valid only for 0 <= T <= 50,
%        which corresponds to 29490 >= r >= 3893

% --- Range check:  correlation is valid only for 3890 <= r <= 29490
ibad = [find(r<3890), find(r>29490)];
if ~isempty(ibad)
  error(sprintf('r = %g is out of range:  3890 <= r <= 29490 Ohm\n',r(ibad)));
end
c = [ 1.025227462259867e-03  2.397895314112997e-04  1.539983937555444e-07];
lnr = log(r);
T = 1./(c(1) + c(2)*lnr + c(3)*lnr.^3) - 273.15;