Homework Assignment ML12b temperature sensor In order to per
Solution
Matlab Code:
% Matlab three variable declarations
R0=100;
A=0.003908;
I=0.15;
% max voltage given is 25
V=25;
% calculating the Resistance Using formula
Rt=V/I;
% A display to the console
disp \'Temperature at max voltage : 25\'
% formula to calculate the temperature
t=((Rt/R0)-1)/A
% redefining voltage to 18
V=18;
Rt=V/I;
disp \'Temperature at voltage : 25\'
% temperature to the console after calculation
t=((Rt/R0)-1)/A
% now to calculate voltage
% the temparature given is 0
t=0;
disp \'Voltage when temperature =0\'
% from the given formula
V=I*R0*(1+A*t)
% array of volts
array=[0 18 25];
disp \'Using arrays\'
% for loop to calculate for each element
for volt=array
% finding resistance first
Rt=volt/I;
%calculating temperature
t=((Rt/R0)-1)/A
% end of the for loop
end
Output:
Temperature at max voltage : 25
t = 170.59
Temperature at voltage : 25
t = 51.177
Voltage when temperature =0
V = 15
Using arrays
t = -255.89
t = 51.177
t = 170.59

