// Calculates the resistance of a thermistor for a range of temperature values
// resistance = R0e^-B((1/T0) -(1/T))
betath=3750;  // obtained from NHQ103B375T10
R0=10e3;
T0=298.15;
T=[273:1:338];
temp=[273:1:338];
Vtemp=[273:1:338];
Vcount=[273:1:338];
count_per_volt=1024/5;
Vref=5;
R1=10e3;


    for i=1:66
    temp(i) = (1/T0)-(1/T(i));
    Rt=R0*exp(-betath*temp);
    Vtemp(i)=Vref*(Rt(i)/(R1+Rt(i)));
    Vcount(i)=(Vtemp(i)*count_per_volt)-512;
    end
    
    clf;
    xgrid(2);
    //plot(T,Vtemp);
    //xtitle("Voltage v temerature", "Temperature K", " Voltage");
    plot(T,Vcount);
    xtitle("ADC counts v temperature", "Temperature K", " ADC counts");
