%RTD_TvsR
%
%This program calculates the temperature given the RTD resistance.
%R = R0 * (1 + A * T + B * T^2)
%(R / R0) = 1 + A * T + B * T^2
%B * T^2 + A * T + (1 - (R / R0)) = 0
%T = {-A +- sqrt[A^2 - 4 * B * (1 - (R / R0))]} / (2 * B)
%
%Zachary Wolf, 2/11/09

%Input parameters
r0 = 100;               %Resistance at 0C (ohm)
a = 3.9083e-3;          %Linear factor (ohm / C)
b = -5.775e-7;          %Quadratic factor (ohm / C^2)

%Calculate the temperature as a function of resistance
%r = [100.000, 100.391, 100.781, 101.172, 101.562, 101.953];
%r = 100. : .3 : 110.;
r = 107.4 : .04 : 108.18;
t = (-a + sqrt(a^2 - 4 * b * (1 - (r / r0)))) / (2 * b);

%Display the results
for ii = 1 : length(r)
    msg = sprintf('R = %8.3f ohm, T = %7.3f C', r(ii), t(ii));
    disp(msg);
end

%Done