天天看點

電阻溫度特性測量matlab代碼

disp("2.電阻溫度特性的測量")
disp("(1)分析銅的溫度特性")
disp("測量資料")
disp("銅絲電阻平均值:")
R_up = [56.34,57.70,58.28,59.24,60.27,61.36,62.55,63.55,64.66,65.99,66.9,67.68,68.88,69.95,71.00,72.10];
R_low = [56.53,57.53,58.63,59.63,60.63,61.71,62.81,63.70,64.51,66.05,67,68.09,68.99,70,71.20,72.20];
R_ = (R_low+R_up)/2

disp("溫度(攝氏度):");
T = 25:5:100

plot(T,R_,'o');
title("銅電阻阻值随溫度變化")
xlabel("T/攝氏度")
ylabel("R_/Ω")
hold on;
plot([25,100],[56.44,72.15],'b');
grid on
hold off;
disp("畫圖法作出的直線斜率(K = R0*a):")
K = (72.25 - 56.44)/(100-26)
R0 = 56.44-K*25;
disp("銅電阻溫度系數:")
a = K/R0
disp("結論:銅電阻随溫度升高而增大,呈線性變化。")


disp("(2)分析NTC熱敏電阻的溫度特性")
%實驗測得NTC熱敏電阻
disp("a.NTC各組電阻的平均值:")
R_NTC_up = [3056.8, 2717.4, 2259.7, 1927.3, 1680.0, 1449.7, 1238.6, 1033.3,...
    893.8, 775.3, 654.4, 576.4, 510.6, 462.5, 406.8, 365.2];
R_NTC_down = [3060.9, 2558.5, 2189.0, 1835.5, 1614.2, 1321.4, 1197.3, 934.1,...
    857.7, 728.4, 633.2, 556.2, 490.11, 434.6, 391.0, 360.8];
R_NTC = (R_NTC_down+R_NTC_up)/2

disp("b.繪制NTC電阻溫度曲線")
plot(T,R_NTC);
title("NTC電阻阻止随溫度變化")
xlabel("T/攝氏度")
ylabel("R_NTC/Ω")
grid on

disp("c.最小二乘法(lnRT = B*(1/T)+lnA,求A,B");
T_1 = 1./T
lnR_NTC = log(R_NTC)
fit = polyfit(T_1,lnR_NTC,1);
B1 = fit(1)
A = exp(fit(2))
disp("");

disp("d.求出激活能E:")
k_ = 1.38e-23
E = B1*k_
disp("");

disp("e.作lnRNTC~1/T曲線");
T__1 = 0:0.0001:0.04;%劃分細區間
lnR_NTC_ = polyval(fit,T__1);%拟合函數
plot(T__1,lnR_NTC_);%畫圖
grid on
xlabel("T^-1")
ylabel("lnR_NTC")
title("lnRT = B*(1/T)+lnA拟合曲線")

disp("NTC電阻随溫度的升高而減小,非線性變化。")

disp("(3)分析PTC熱敏電阻的溫度特性")
%實驗測得PTC熱敏電阻
disp("a.PTC各組電阻的平均值:")
R_PTC_up = [314.2, 350.9, 382.7, 423.1, 466.9, 516.2, 574.9, 631.8, 710.1,...
    777.2, 847.5, 886.4, 962.2, 1038.1, 1116.4, 1197.7];
R_PTC_down = [307.6, 339.9, 376.2, 418.0, 482.7, 513.4, 566.1, 633.0, 693.4,...
    744.5, 812.8, 882.8, 957.1, 1035.7, 1114.8, 1196.7];
R_PTC = (R_PTC_down+R_PTC_up)/2

disp("b.繪制PTC電阻溫度曲線")
plot(T,R_PTC);
title("PTC電阻阻止随溫度變化")
xlabel("T/攝氏度")
ylabel("R_NTC/Ω")
grid on

disp("c.最小二乘法(lnRT = B2*T+C,求B");
lnR_PTC = log(R_PTC)
fit2 = polyfit(T,lnR_PTC,1);
B2 = fit2(1)
disp("");

disp("d.作lnRPTC~1/T曲線:")
lnR_PTC_ = polyval(fit2,T1);%拟合函數
plot(T1,lnR_PTC_);%畫圖
grid on
xlabel("T")
ylabel("lnR_PTC")
title("lnRT = B2*T+C拟合曲線")

disp("PTC電阻随溫度的升高而增大,非線性變化。")

disp("課後思考題:")
plot(T,R_,'o');
title("銅電阻阻止随溫度變化——用最小二乘法拟合")
xlabel("T/攝氏度")
ylabel("R_/Ω")
grid on
hold on;
disp("最小二乘法函數求出k,b")
k = polyfit(T,R_,1);
T1 = 25:0.01:100;%劃分區間
R1 = polyval(k,T1);
plot(T1,R1,'r')
hold off;
disp("a = " + k(1)/k(2));
           

繼續閱讀