主要内容

ppval.

评估分段多项式

Description

example

v= ppval(,xq)evaluates the piecewise polynomialat the query pointsxq.

Examples

collapse all

Create a piecewise polynomial that has a cubic polynomial in the interval [0,4], a quadratic polynomial in the interval [4,10], and a quartic polynomial in the interval [10,15].

断裂= [0 4 10 15];COEFS = [0 1 -1 1 1;0 0 1 -2 53;-1 6 1 4 77];PP = MKPP(休息,COEFS)
页=struct with fields:形式:'PP'断裂:[0 4 10 15] COEFS:[3x5双]碎片:3级:5次点:1

Evaluate the piecewise polynomial at many points in the interval [0,15] and plot the results. Plot vertical dashed lines at the break points where the polynomials meet.

xq = 0:0.01:15; plot(xq,ppval(pp,xq)) line([4 4],ylim,'linestyle','--','颜色','k') line([10 10],ylim,'linestyle','--','颜色','k')

Figure contains an axes object. The axes object contains 3 objects of type line.

创建和绘制分段多项式,四个间隔在两个二次多项式之间交替。

The first two subplots show a quadratic polynomial and its negation shifted to the intervals [-8,-4] and [-4,0]. The polynomial is

1 - ( x 2 - 1 ) 2 = - x 2 4 + x .

The third subplot shows a piecewise polynomial constructed by alternating these two quadratic pieces over four intervals. Vertical lines are added to show the points where the polynomials meet.

subplot(2,2,1) cc = [-1/4 1 0]; pp1 = mkpp([-8 -4],cc); xx1 = -8:0.1:-4; plot(xx1,ppval(pp1,xx1),'k-') subplot(2,2,2) pp2 = mkpp([-4 0],-cc); xx2 = -4:0.1:0; plot(xx2,ppval(pp2,xx2),'k-') subplot(2,1,2) pp = mkpp([-8 -4 0 4 8],[cc;-cc;cc;-cc]); xx = -8:0.1:8; plot(xx,ppval(pp,xx),'k-') 抓住线([ -  4 -4],ylim,'linestyle','--') line([0 0],ylim,'linestyle','--') line([4 4],ylim,'linestyle','--') 抓住off

Figure contains 3 axes objects. Axes object 1 contains an object of type line. Axes object 2 contains an object of type line. Axes object 3 contains 4 objects of type line.

Input Arguments

collapse all

Piecewise polynomial, specified as a structure. You can createusingspline,pchip,makima,interp1,或样条型实用程序功能mkpp.

查询点, specified as a vector or array.xq指定点ppval.evaluates the piecewise polynomial.

Data Types:single|double

Output Arguments

collapse all

在查询点处的分段多项式值,返回为向量,矩阵或数组。

Ifhas[d1,..,dr]-valued coefficients (nonscalar coefficient values), then:

  • Whenxqis a vector of lengthN,vhas size[d1,...,dr,N], 和v(:,...,:,j)是价值xq(j).

  • Whenxqhas size[n1,...,ns],vhas size[d1,...,dr,N1,...,Ns], 和v(:,...,:, j1,...,js)是价值xq(j1,...,js).

Extended Capabilities

在R2006A之前介绍