您的位置:首页 > 编程语言 > MATLAB

电阻温度特性测量matlab代码

2019-03-20 19:23 465 查看
[code]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));

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: