[英]Matlab: Getting the Coefficients of Piecewise Cubic Hermite Interpolating Polynomial
I want to fit a curve to some data. 我想对某些数据拟合曲线。 I used a PCHIP interpolation because of getting the best results.
我使用PCHIP插值是因为获得了最佳结果。 Moreover, I want to get the coefficients for the 6 intervals with the
ppval-function
. 此外,我想用
ppval-function
获得6个区间的系数。 But there pops up an error like these: 但是会弹出如下错误:
Error using unmkpp (line 18)
The input array does not seem to describe a pp function.
Error in ppval (line 62)
[b,c,l,k,dd]=unmkpp(pp);
Error in SA (line 8)
v = ppval(p,xdata)
This is my code: 这是我的代码:
clear all
xdata = [0; 3.5; 6.8; 7.6; 8.2; 30; 34.2];
ydata = [0; 50; 400000; 2000000; 25000000; 100000000;100000000]
xq1 = 0:0.01:35;
p = pchip(xdata,ydata, xq1);
s = spline(xdata,ydata,xq1);
v = ppval(p,xdata)
plot(xdata,ydata,'o',xq1,p,'-',xq1,s,'-.');
legend('Datenpunkte','pchip','spline','Location','SouthEast');
Can you help me? 你能帮助我吗?
Best regards Dominik 最好的问候多米尼克
pchip
has two working modes: pchip
有两种工作模式:
Calculating the piecewise polynomial coefficients: pp = pchip(x,y)
: 计算分段多项式系数:
pp = pchip(x,y)
:
returns a piecewise polynomial structure for use with
ppval
返回用于
ppval
的分段多项式结构
Interpolating at specified points: p = pchip(x,y,xq)
: 在指定点插值:
p = pchip(x,y,xq)
:
is the same as
p = ppval(pchip(x,y),xq)
与
p = ppval(pchip(x,y),xq)
returns a vector of interpolated values p corresponding to the query points in xq
返回与xq中的查询点相对应的内插值p的向量
So, you are using the second mode, which is not suited for use with ppval
. 因此,您正在使用第二种模式,该模式不适用于
ppval
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.