如何在python中计算多项式函数?

2024-06-13 07:55:07 发布

您现在位置:Python中文网/ 问答频道 /正文

enter image description here

我使用原始数据(红色曲线)绘制了面积[x轴]和高程[y轴]的曲线。现在我有了新的高程系列,我想得到新的面积系列值。为此,我使用python中的polyfit函数拟合了三阶多项式(绿色曲线)

import numpy as np
from matplotlib import pyplot as plt


p= np.polyfit(area, Elv, 3)
plt.plot(area, Elv, 'r-')
plt.plot(area,np.polyval(p, area),'g----')
plt.xlabel('Area')
plt.ylabel('Elevation')

如何根据新的高程系列,即f(x),得到多项式f ( x ) = 3ax + 2ax + cx + d中x[面积]的值


Tags:
函数import原始数据plotasnp绘制plt