%RTD_RcalcT
%
%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)
%
%Input:
%r, RTD resistance (ohm)
%
%Output:
%t, temperature (deg C)
%
%Zachary Wolf, 2/25/09

function [t] = RTD_RcalcT(r)

%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
t = (-a + sqrt(a^2 - 4 * b * (1 - (r / r0)))) / (2 * b);

%Done