% A resistors changes with temperature, Eq. (5.1) and Fig. 5.1 in CMOS Circuit Design,
% Layout, and Simulation
clear all; clc;
TCR1 = 2000e-6; %temperature coefficient, TCR1, here 2,000 ppm/C (or per K)
To = 300; % room temperature, To, in Kelvin
Ro = 1e3; % resistor's value, Ro, at room temperature R(To)
Tmin=200; Tmax=400; % plot resistor's change from 200K to 400K
T = Tmin:Tmax;
R = Ro*(1+TCR1*(T-To)); % compute resistor's value vs temperature
T = T-273; %convert to Celsius
plot(T, R, 'lineWidth', 2) % plot Resistance vs. Temperature
xlim([Tmin-300 Tmax-250]);
k = length(R);
ylim([R(1)-100 R(k)+100]); %put a little space at the top and bottom of the y-axis
title('Resistors value change with temperature')
xlabel('Temperature (Celsius)')
ylabel('Resistance (Ohms)')
grid on;
