The resistance of a typical carbon film resistor will decrea
The resistance of a typical carbon film resistor will decrease by about 0.05% of its stated value
 for each degree Celsius increase in temperature. Silicon is very sensitive to temperature, decreasing its resistance by about 7% for each degree Celsius increase in temperature. This can
 be a serious problem in modern electronics and computers since silicon is the primary material
 from which many electronic devices are fabricated.
 Create a proper plot to compare a carbon film resistor with a resistor fabricated from specially
 doped silicon (“doped” means impurities such as phosphorus or boron have been added
 to the silicon).
 For relatively small temperature differences from the reference temperature, this process is
 essentially linear. Use polyfit to determine linear models for each data set. For each model,
 add the trendline and the associated trendline equation to the graph. Use an appropriate location
 for the equations to clearly associate them with the correct trendline.
 Resistance (R) []
 Temperature (T)[°C] Carbon Film Doped Silicon
 15 10.050 10.15
 20 10.048 9.85
 25 10.045 9.48
Need to be done in MATLAB
Solution
Code:
Temp = [15 20 25];
 Carbon = [10.05 10.048 10.047]
 Silicon = [10.15 9.85 9.48]
 sigma_xy=0
 sigma_x = 0
 sigma_x_2 = 0
 sigma_y=0
 for i=1:length(Temp)
    sigma_xy = sigma_xy + (Temp(i)* Carbon(i))
    sigma_x = sigma_x + Temp(i)
    sigma_y = sigma_y + Carbon(i)
    sigma_x_2 = sigma_x_2 + (Temp(i)* Temp(i))
 end
 n=length(Temp)
 slope_carbon = ((n*sigma_xy) - (sigma_x * sigma_y)) / ((n*sigma_x_2)- (sigma_x*sigm_x))
 offset_carbon = (sigma_y - ((slope_carbon )* sigma_x))/n
 sigma_y=0
 sigma_xy=0
 sigma_x = 0
 sigma_x_2 = 0
 for i=1:length(Temp)
    sigma_xy = sigma_xy + (Temp(i)* Silicon(1))
    sigma_x = sigma_x + Temp(i)
    sigma_y = sigma_y + Silicon(i)
    sigma_x_2 = sigma_x_2 + (Temp(i)* Temp(i))
 end
 n=length(Temp)
 slope_silicon = ((n*sigma_xy) - (sigma_x * sigma_y)) / ((n*sigma_x_2)- (sigma_x*sigm_x))
 offset_silicon = (sigma_y - ((slope_carbon )* sigma_x))/n
 for x=1:25
 y_carb= (slope_carbon *x) +offset_carbon
 y_sili= (slope_silicon *x) +offset_silicon
 end
 plot(y_carb,y_sili)

