import numpy as np
import matplotlib.pyplot as plt
Temp = []
R1 = []
B = 3950
R0 = 100000
Rt = []
T1 = []
K = 273.15
#RT.csv為數據檔,請改成要匯入的檔名
with open('RT.csv','r',encoding='utf-8-sig') as f:
s = f.read()
b = s.split()
for i in b:
c=i.split(',')
Temp.append(float(c[0]))
R1.append(float(c[1]))
print(len(Temp))
print(len(R1))
def R_t(T):
r = R0*np.exp((B)*(1/(T+K)-1/(25+K)))
return r
for i in range(30,62,2):
y = R_t(i)
Rt.append(y)
T1.append(i)
plt.plot(T1,Rt)
plt.plot(Temp,R1,"o")
plt.show()
Rt_n = np.array(Rt)
R1_n = np.array(R1)
plt.plot(T1,np.abs(Rt_n-R1_n)/Rt_n*100)
plt.show()
print(np.abs(Rt_n-R1_n)/Rt_n*100)
[12.48463944 11.71416852 11.59804034 10.7631062 9.15916582 8.59773664 7.6841433 4.4412353 3.6598145 1.95164032 0.2397516 1.88406097 3.48059623 5.59037778]