简体   繁体   English

Matlab:获取分段三次Hermite插值多项式的系数

[英]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.

相关问题 在MATLAB中给定数据的分段三次Hermite插值多项式(PCHIP),然后查找区域 - Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) for given data in MATLAB and then finding area 将 Hermite 多项式的系数转换为函数 - Сonvert the coefficients of the Hermite polynomial into a function 分段立方Hermite插值器的根与python - roots of piecewise cubic hermite interpolator with python 在Matlab中获取符号多项式的系数 - Get coefficients of symbolic polynomial in Matlab Matlab - 具有不同系数的多项式的根 - Matlab - Roots of polynomial with varying coefficients MATLAB:使用ppval评估分段多项式(pchip) - MATLAB: evaluation of a piecewise polynomial (pchip) with ppval 多项式拟合matlab对系数有一些约束 - Polynomial fit matlab with some constraints on the coefficients MATLAB:该函数用于计算通过将其他两个多项式相乘而形成的多项式的系数 - MATLAB: Function that computes the coefficients of the polynomial that is formed by multiplying 2 other polynomials MATLAB中的Hermite插值多项式 - Hermite interpolation polynom in MATLAB Matlab如何定义矩阵中的系数来计算多项式的根 - Matlab how to define coefficients in a matrix to compute the roots of a polynomial
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM