x0=[0 300 600 1000 1500 2000]; y0=[0.9689 0.9322 0.8969 0.8519 0.7989 0.7491]; x=0:100:2000;y=interp1(x0,y0,x,'spline');plot(x0,y0,'k+',x,y,'r') x0=[0 300 600 1000 1500 2000]; y0=[0.9689 0.9322 0.8969 0.8519 0.7989 0.7491]; A=polyfit(x0,y0,2),z=polyval(A,x0),plot(x0,y0,'k+',x0,z,'r') 结果:A =【 0.0000 -0.0001 0.9688】 x=0:100:2000;y=-0.0001.*x+0.9668 y = Columns 1 through 9 0.9668 0.9568 0.9468 0.9368 0.9268 0.9168 0.9068 0.8968 0.8868 Columns 10 through 18 0.8768 0.8668 0.8568 0.8468 0.8368 0.8268 0.8168 0.8068 0.7968 Columns 19 through 21 0.7868 0.7768 0.7668 与理论计算公式计算比较 x=0:100:2000;y=1.0332.*exp((x+500)/(-7756)); plot(x,y) x=0:100:2000;y=1.0332.*exp((x+500)/(-7756)) y = Columns 1 through 9 0.9687 0.9563 0.9440 0.9319 0.9200 0.9082 0.8966 0.8851 0.8738 Columns 10 through 18 0.8626 0.8515 0.8406 0.8298 0.8192 0.8087 0.7984 0.7881 0.7780 Columns 19 through 21 0.7681 0.7582 0.7485 ~~~ 转为python语言
时间: 2024-02-15 15:28:20 浏览: 125
import numpy as np
import matplotlib.pyplot as plt
x0 = [0, 300, 600, 1000, 1500, 2000]
y0 = [0.9689, 0.9322, 0.8969, 0.8519, 0.7989, 0.7491]
# Spline Interpolation
x = np.arange(0, 2001, 100)
y = np.interp(x, x0, y0, 'spline')
plt.plot(x0, y0, 'k+', x, y, 'r')
# Polynomial Fitting
A = np.polyfit(x0, y0, 2)
z = np.polyval(A, x0)
plt.plot(x0, y0, 'k+', x0, z, 'r')
# Theory Calculation
x = np.arange(0, 2001, 100)
y = 1.0332*np.exp((x+500)/(-7756))
plt.plot(x, y)
plt.show()
阅读全文