Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 641ebb3060c35990cc021d8f7aaf9aca > files > 416

octave-doc-5.1.0-7.1.mga7.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Polynomial Interpolation (GNU Octave (version 5.1.0))</title>

<meta name="description" content="Polynomial Interpolation (GNU Octave (version 5.1.0))">
<meta name="keywords" content="Polynomial Interpolation (GNU Octave (version 5.1.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Polynomial-Manipulations.html#Polynomial-Manipulations" rel="up" title="Polynomial Manipulations">
<link href="Miscellaneous-Functions.html#Miscellaneous-Functions" rel="next" title="Miscellaneous Functions">
<link href="Derivatives-_002f-Integrals-_002f-Transforms.html#Derivatives-_002f-Integrals-_002f-Transforms" rel="prev" title="Derivatives / Integrals / Transforms">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">


</head>

<body lang="en">
<a name="Polynomial-Interpolation"></a>
<div class="header">
<p>
Next: <a href="Miscellaneous-Functions.html#Miscellaneous-Functions" accesskey="n" rel="next">Miscellaneous Functions</a>, Previous: <a href="Derivatives-_002f-Integrals-_002f-Transforms.html#Derivatives-_002f-Integrals-_002f-Transforms" accesskey="p" rel="prev">Derivatives / Integrals / Transforms</a>, Up: <a href="Polynomial-Manipulations.html#Polynomial-Manipulations" accesskey="u" rel="up">Polynomial Manipulations</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Polynomial-Interpolation-1"></a>
<h3 class="section">28.5 Polynomial Interpolation</h3>

<p>Octave comes with good support for various kinds of interpolation,
most of which are described in <a href="Interpolation.html#Interpolation">Interpolation</a>.  One simple alternative
to the functions described in the aforementioned chapter, is to fit
a single polynomial, or a piecewise polynomial (spline) to some given
data points.  To avoid a highly fluctuating polynomial, one most often
wants to fit a low-order polynomial to data.  This usually means that it
is necessary to fit the polynomial in a least-squares sense, which just
is what the <code>polyfit</code> function does.
</p>
<a name="XREFpolyfit"></a><dl>
<dt><a name="index-polyfit"></a><em><var>p</var> =</em> <strong>polyfit</strong> <em>(<var>x</var>, <var>y</var>, <var>n</var>)</em></dt>
<dt><a name="index-polyfit-1"></a><em>[<var>p</var>, <var>s</var>] =</em> <strong>polyfit</strong> <em>(<var>x</var>, <var>y</var>, <var>n</var>)</em></dt>
<dt><a name="index-polyfit-2"></a><em>[<var>p</var>, <var>s</var>, <var>mu</var>] =</em> <strong>polyfit</strong> <em>(<var>x</var>, <var>y</var>, <var>n</var>)</em></dt>
<dd><p>Return the coefficients of a polynomial <var>p</var>(<var>x</var>) of degree
<var>n</var> that minimizes the least-squares-error of the fit to the points
<code>[<var>x</var>, <var>y</var>]</code>.
</p>
<p>If <var>n</var> is a logical vector, it is used as a mask to selectively force
the corresponding polynomial coefficients to be used or ignored.
</p>
<p>The polynomial coefficients are returned in a row vector.
</p>
<p>The optional output <var>s</var> is a structure containing the following fields:
</p>
<dl compact="compact">
<dt>&lsquo;<samp>R</samp>&rsquo;</dt>
<dd><p>Triangular factor R from the QR&nbsp;decomposition.
</p>
</dd>
<dt>&lsquo;<samp>X</samp>&rsquo;</dt>
<dd><p>The Vandermonde matrix used to compute the polynomial
coefficients.
</p>
</dd>
<dt>&lsquo;<samp>C</samp>&rsquo;</dt>
<dd><p>The unscaled covariance matrix, formally equal to the inverse of
<var>x&rsquo;</var>*<var>x</var>, but computed in a way minimizing roundoff error
propagation.
</p>
</dd>
<dt>&lsquo;<samp>df</samp>&rsquo;</dt>
<dd><p>The degrees of freedom.
</p>
</dd>
<dt>&lsquo;<samp>normr</samp>&rsquo;</dt>
<dd><p>The norm of the residuals.
</p>
</dd>
<dt>&lsquo;<samp>yf</samp>&rsquo;</dt>
<dd><p>The values of the polynomial for each value of <var>x</var>.
</p></dd>
</dl>

<p>The second output may be used by <code>polyval</code> to calculate the
statistical error limits of the predicted values.  In particular, the
standard deviation of <var>p</var> coefficients is given by
</p>
<p><code>sqrt (diag (s.C)/s.df)*s.normr</code>.
</p>
<p>When the third output, <var>mu</var>, is present the coefficients, <var>p</var>, are
associated with a polynomial in
</p>
<p><code><var>xhat</var> = (<var>x</var> - <var>mu</var>(1)) / <var>mu</var>(2)</code> <br>
where <var>mu</var>(1) = mean (<var>x</var>), and <var>mu</var>(2) = std (<var>x</var>).
</p>
<p>This linear transformation of <var>x</var> improves the numerical stability of
the fit.
</p>
<p><strong>See also:</strong> <a href="Evaluating-Polynomials.html#XREFpolyval">polyval</a>, <a href="Derivatives-_002f-Integrals-_002f-Transforms.html#XREFpolyaffine">polyaffine</a>, <a href="Finding-Roots.html#XREFroots">roots</a>, <a href="Famous-Matrices.html#XREFvander">vander</a>, <a href="Basic-Statistical-Functions.html#XREFzscore">zscore</a>.
</p></dd></dl>


<p>In situations where a single polynomial isn&rsquo;t good enough, a solution
is to use several polynomials pieced together.  The function
<code>splinefit</code> fits a piecewise polynomial (spline) to a set of
data.
</p>
<a name="XREFsplinefit"></a><dl>
<dt><a name="index-splinefit"></a><em><var>pp</var> =</em> <strong>splinefit</strong> <em>(<var>x</var>, <var>y</var>, <var>breaks</var>)</em></dt>
<dt><a name="index-splinefit-1"></a><em><var>pp</var> =</em> <strong>splinefit</strong> <em>(<var>x</var>, <var>y</var>, <var>p</var>)</em></dt>
<dt><a name="index-splinefit-2"></a><em><var>pp</var> =</em> <strong>splinefit</strong> <em>(&hellip;, &quot;periodic&quot;, <var>periodic</var>)</em></dt>
<dt><a name="index-splinefit-3"></a><em><var>pp</var> =</em> <strong>splinefit</strong> <em>(&hellip;, &quot;robust&quot;, <var>robust</var>)</em></dt>
<dt><a name="index-splinefit-4"></a><em><var>pp</var> =</em> <strong>splinefit</strong> <em>(&hellip;, &quot;beta&quot;, <var>beta</var>)</em></dt>
<dt><a name="index-splinefit-5"></a><em><var>pp</var> =</em> <strong>splinefit</strong> <em>(&hellip;, &quot;order&quot;, <var>order</var>)</em></dt>
<dt><a name="index-splinefit-6"></a><em><var>pp</var> =</em> <strong>splinefit</strong> <em>(&hellip;, &quot;constraints&quot;, <var>constraints</var>)</em></dt>
<dd>
<p>Fit a piecewise cubic spline with breaks (knots) <var>breaks</var> to the
noisy data, <var>x</var> and <var>y</var>.
</p>
<p><var>x</var> is a vector, and <var>y</var> is a vector or N-D array.  If <var>y</var> is an
N-D array, then <var>x</var>(j) is matched to <var>y</var>(:,&hellip;,:,j).
</p>
<p><var>p</var> is a positive integer defining the number of intervals along
<var>x</var>, and <var>p</var>+1 is the number of breaks.  The number of points in
each interval differ by no more than 1.
</p>
<p>The optional property <var>periodic</var> is a logical value which specifies
whether a periodic boundary condition is applied to the spline.  The
length of the period is <code>max (<var>breaks</var>) - min (<var>breaks</var>)</code>.
The default value is <code>false</code>.
</p>
<p>The optional property <var>robust</var> is a logical value which specifies
if robust fitting is to be applied to reduce the influence of outlying
data points.  Three iterations of weighted least squares are performed.
Weights are computed from previous residuals.  The sensitivity of outlier
identification is controlled by the property <var>beta</var>.  The value of
<var>beta</var> is restricted to the range, 0 &lt; <var>beta</var> &lt; 1.  The default
value is <var>beta</var> = 1/2.  Values close to 0 give all data equal
weighting.  Increasing values of <var>beta</var> reduce the influence of
outlying data.  Values close to unity may cause instability or rank
deficiency.
</p>
<p>The fitted spline is returned as a piecewise polynomial, <var>pp</var>, and
may be evaluated using <code>ppval</code>.
</p>
<p>The splines are constructed of polynomials with degree <var>order</var>.
The default is a cubic, <var>order</var>=3.  A spline with P pieces has
P+<var>order</var> degrees of freedom.  With periodic boundary conditions
the degrees of freedom are reduced to P.
</p>
<p>The optional property, <var>constraints</var>, is a structure specifying linear
constraints on the fit.  The structure has three fields, <code>&quot;xc&quot;</code>,
<code>&quot;yc&quot;</code>, and <code>&quot;cc&quot;</code>.
</p>
<dl compact="compact">
<dt><code>&quot;xc&quot;</code></dt>
<dd><p>Vector of the x-locations of the constraints.
</p>
</dd>
<dt><code>&quot;yc&quot;</code></dt>
<dd><p>Constraining values at the locations <var>xc</var>.
The default is an array of zeros.
</p>
</dd>
<dt><code>&quot;cc&quot;</code></dt>
<dd><p>Coefficients (matrix).  The default is an array of ones.  The number of
rows is limited to the order of the piecewise polynomials, <var>order</var>.
</p></dd>
</dl>

<p>Constraints are linear combinations of derivatives of order 0 to
<var>order</var>-1 according to
</p>
<div class="example">
<pre class="example">cc(1,j) * y(xc(j)) + cc(2,j) * y'(xc(j)) + ... = yc(:,...,:,j).
</pre></div>


<p><strong>See also:</strong> <a href="One_002ddimensional-Interpolation.html#XREFinterp1">interp1</a>, <a href="#XREFunmkpp">unmkpp</a>, <a href="#XREFppval">ppval</a>, <a href="One_002ddimensional-Interpolation.html#XREFspline">spline</a>, <a href="Signal-Processing.html#XREFpchip">pchip</a>, <a href="#XREFppder">ppder</a>, <a href="#XREFppint">ppint</a>, <a href="#XREFppjumps">ppjumps</a>.
</p></dd></dl>


<p>The number of <var>breaks</var> (or knots) used to construct the piecewise
polynomial is a significant factor in suppressing the noise present in
the input data, <var>x</var> and <var>y</var>.  This is demonstrated by the example
below.
</p>
<div class="example">
<pre class="example">x = 2 * pi * rand (1, 200);
y = sin (x) + sin (2 * x) + 0.2 * randn (size (x));
## Uniform breaks
breaks = linspace (0, 2 * pi, 41); % 41 breaks, 40 pieces
pp1 = splinefit (x, y, breaks);
## Breaks interpolated from data
pp2 = splinefit (x, y, 10);  % 11 breaks, 10 pieces
## Plot
xx = linspace (0, 2 * pi, 400);
y1 = ppval (pp1, xx);
y2 = ppval (pp2, xx);
plot (x, y, &quot;.&quot;, xx, [y1; y2])
axis tight
ylim auto
legend ({&quot;data&quot;, &quot;41 breaks, 40 pieces&quot;, &quot;11 breaks, 10 pieces&quot;})
</pre></div>

<p>The result of which can be seen in <a href="#fig_003asplinefit1">Figure 28.1</a>.
</p>
<div class="float"><a name="fig_003asplinefit1"></a>
<div align="center"><img src="splinefit1.png" alt="splinefit1">
</div>
<div class="float-caption"><p><strong>Figure 28.1: </strong>Comparison of a fitting a piecewise polynomial with 41 breaks to one
with 11 breaks.  The fit with the large number of breaks exhibits a fast ripple
that is not present in the underlying function.</p></div></div>
<p>The piecewise polynomial fit, provided by <code>splinefit</code>, has
continuous derivatives up to the <var>order</var>-1.  For example, a cubic fit
has continuous first and second derivatives.  This is demonstrated by
the code
</p>
<div class="example">
<pre class="example">## Data (200 points)
x = 2 * pi * rand (1, 200);
y = sin (x) + sin (2 * x) + 0.1 * randn (size (x));
## Piecewise constant
pp1 = splinefit (x, y, 8, &quot;order&quot;, 0);
## Piecewise linear
pp2 = splinefit (x, y, 8, &quot;order&quot;, 1);
## Piecewise quadratic
pp3 = splinefit (x, y, 8, &quot;order&quot;, 2);
## Piecewise cubic
pp4 = splinefit (x, y, 8, &quot;order&quot;, 3);
## Piecewise quartic
pp5 = splinefit (x, y, 8, &quot;order&quot;, 4);
## Plot
xx = linspace (0, 2 * pi, 400);
y1 = ppval (pp1, xx);
y2 = ppval (pp2, xx);
y3 = ppval (pp3, xx);
y4 = ppval (pp4, xx);
y5 = ppval (pp5, xx);
plot (x, y, &quot;.&quot;, xx, [y1; y2; y3; y4; y5])
axis tight
ylim auto
legend ({&quot;data&quot;, &quot;order 0&quot;, &quot;order 1&quot;, &quot;order 2&quot;, &quot;order 3&quot;, &quot;order 4&quot;})
</pre></div>

<p>The result of which can be seen in <a href="#fig_003asplinefit2">Figure 28.2</a>.
</p>
<div class="float"><a name="fig_003asplinefit2"></a>
<div align="center"><img src="splinefit2.png" alt="splinefit2">
</div>
<div class="float-caption"><p><strong>Figure 28.2: </strong>Comparison of a piecewise constant, linear, quadratic, cubic, and
quartic polynomials with 8 breaks to noisy data.  The higher order solutions
more accurately represent the underlying function, but come with the
expense of computational complexity.</p></div></div>
<p>When the underlying function to provide a fit to is periodic, <code>splinefit</code>
is able to apply the boundary conditions needed to manifest a periodic fit.
This is demonstrated by the code below.
</p>
<div class="example">
<pre class="example">## Data (100 points)
x = 2 * pi * [0, (rand (1, 98)), 1];
y = sin (x) - cos (2 * x) + 0.2 * randn (size (x));
## No constraints
pp1 = splinefit (x, y, 10, &quot;order&quot;, 5);
## Periodic boundaries
pp2 = splinefit (x, y, 10, &quot;order&quot;, 5, &quot;periodic&quot;, true);
## Plot
xx = linspace (0, 2 * pi, 400);
y1 = ppval (pp1, xx);
y2 = ppval (pp2, xx);
plot (x, y, &quot;.&quot;, xx, [y1; y2])
axis tight
ylim auto
legend ({&quot;data&quot;, &quot;no constraints&quot;, &quot;periodic&quot;})
</pre></div>

<p>The result of which can be seen in <a href="#fig_003asplinefit3">Figure 28.3</a>.
</p>
<div class="float"><a name="fig_003asplinefit3"></a>
<div align="center"><img src="splinefit3.png" alt="splinefit3">
</div>
<div class="float-caption"><p><strong>Figure 28.3: </strong>Comparison of piecewise polynomial fits to a noisy periodic
function with, and without, periodic boundary conditions.</p></div></div>
<p>More complex constraints may be added as well.  For example, the code below
illustrates a periodic fit with values that have been clamped at the endpoints,
and a second periodic fit which is hinged at the endpoints.
</p>
<div class="example">
<pre class="example">## Data (200 points)
x = 2 * pi * rand (1, 200);
y = sin (2 * x) + 0.1 * randn (size (x));
## Breaks
breaks = linspace (0, 2 * pi, 10);
## Clamped endpoints, y = y' = 0
xc = [0, 0, 2*pi, 2*pi];
cc = [(eye (2)), (eye (2))];
con = struct (&quot;xc&quot;, xc, &quot;cc&quot;, cc);
pp1 = splinefit (x, y, breaks, &quot;constraints&quot;, con);
## Hinged periodic endpoints, y = 0
con = struct (&quot;xc&quot;, 0);
pp2 = splinefit (x, y, breaks, &quot;constraints&quot;, con, &quot;periodic&quot;, true);
## Plot
xx = linspace (0, 2 * pi, 400);
y1 = ppval (pp1, xx);
y2 = ppval (pp2, xx);
plot (x, y, &quot;.&quot;, xx, [y1; y2])
axis tight
ylim auto
legend ({&quot;data&quot;, &quot;clamped&quot;, &quot;hinged periodic&quot;})
</pre></div>

<p>The result of which can be seen in <a href="#fig_003asplinefit4">Figure 28.4</a>.
</p>
<div class="float"><a name="fig_003asplinefit4"></a>
<div align="center"><img src="splinefit4.png" alt="splinefit4">
</div>
<div class="float-caption"><p><strong>Figure 28.4: </strong>Comparison of two periodic piecewise cubic fits to a noisy periodic
signal.  One fit has its endpoints clamped and the second has its endpoints
hinged.</p></div></div>
<p>The <code>splinefit</code> function also provides the convenience of a <var>robust</var>
fitting, where the effect of outlying data is reduced.  In the example below,
three different fits are provided.  Two with differing levels of outlier
suppression and a third illustrating the non-robust solution.
</p>
<div class="example">
<pre class="example">## Data
x = linspace (0, 2*pi, 200);
y = sin (x) + sin (2 * x) + 0.05 * randn (size (x));
## Add outliers
x = [x, linspace(0,2*pi,60)];
y = [y, -ones(1,60)];
## Fit splines with hinged conditions
con = struct (&quot;xc&quot;, [0, 2*pi]);
## Robust fitting, beta = 0.25
pp1 = splinefit (x, y, 8, &quot;constraints&quot;, con, &quot;beta&quot;, 0.25);
## Robust fitting, beta = 0.75
pp2 = splinefit (x, y, 8, &quot;constraints&quot;, con, &quot;beta&quot;, 0.75);
## No robust fitting
pp3 = splinefit (x, y, 8, &quot;constraints&quot;, con);
## Plot
xx = linspace (0, 2*pi, 400);
y1 = ppval (pp1, xx);
y2 = ppval (pp2, xx);
y3 = ppval (pp3, xx);
plot (x, y, &quot;.&quot;, xx, [y1; y2; y3])
legend ({&quot;data with outliers&quot;,&quot;robust, beta = 0.25&quot;, ...
         &quot;robust, beta = 0.75&quot;, &quot;no robust fitting&quot;})
axis tight
ylim auto
</pre></div>

<p>The result of which can be seen in <a href="#fig_003asplinefit6">Figure 28.5</a>.
</p>
<div class="float"><a name="fig_003asplinefit6"></a>
<div align="center"><img src="splinefit6.png" alt="splinefit6">
</div>
<div class="float-caption"><p><strong>Figure 28.5: </strong>Comparison of two different levels of robust fitting (<var>beta</var> = 0.25 and 0.75) to noisy data combined with outlying data.  A conventional fit, without
robust fitting (<var>beta</var> = 0) is also included.</p></div></div>
<p>A very specific form of polynomial interpretation is the Pad&eacute; approximant.
For control systems, a continuous-time delay can be modeled very simply with
the approximant.
</p>
<a name="XREFpadecoef"></a><dl>
<dt><a name="index-padecoef"></a><em>[<var>num</var>, <var>den</var>] =</em> <strong>padecoef</strong> <em>(<var>T</var>)</em></dt>
<dt><a name="index-padecoef-1"></a><em>[<var>num</var>, <var>den</var>] =</em> <strong>padecoef</strong> <em>(<var>T</var>, <var>N</var>)</em></dt>
<dd><p>Compute the <var>N</var>th-order Pad&eacute; approximant of the continuous-time
delay <var>T</var> in transfer function form.
</p>
<p>The Pad&eacute; approximant of <code>exp (-sT)</code> is defined by the
following equation
</p>
<div class="example">
<pre class="example">             Pn(s)
exp (-sT) ~ -------
             Qn(s)
</pre></div>

<p>Where both Pn(s) and Qn(s) are <var>N</var>th-order rational functions
defined by the following expressions
</p>
<div class="example">
<pre class="example">         N    (2N - k)!N!        k
Pn(s) = SUM --------------- (-sT)
        k=0 (2N)!k!(N - k)!

Qn(s) = Pn(-s)
</pre></div>


<p>The inputs <var>T</var> and <var>N</var> must be non-negative numeric scalars.  If
<var>N</var> is unspecified it defaults to 1.
</p>
<p>The output row vectors <var>num</var> and <var>den</var> contain the numerator and
denominator coefficients in descending powers of s.  Both are
<var>N</var>th-order polynomials.
</p>
<p>For example:
</p>
<div class="smallexample">
<pre class="smallexample">t = 0.1;
n = 4;
[num, den] = padecoef (t, n)
&rArr; num =

      1.0000e-04  -2.0000e-02   1.8000e+00  -8.4000e+01   1.6800e+03

&rArr; den =

      1.0000e-04   2.0000e-02   1.8000e+00   8.4000e+01   1.6800e+03
</pre></div>
</dd></dl>


<p>The function, <code>ppval</code>, evaluates the piecewise polynomials, created
by <code>mkpp</code> or other means, and <code>unmkpp</code> returns detailed
information about the piecewise polynomial.
</p>
<p>The following example shows how to combine two linear functions and a
quadratic into one function.  Each of these functions is expressed
on adjoined intervals.
</p>
<div class="example">
<pre class="example">x = [-2, -1, 1, 2];
p = [ 0,  1, 0;
      1, -2, 1;
      0, -1, 1 ];
pp = mkpp (x, p);
xi = linspace (-2, 2, 50);
yi = ppval (pp, xi);
plot (xi, yi);
</pre></div>

<a name="XREFmkpp"></a><dl>
<dt><a name="index-mkpp"></a><em><var>pp</var> =</em> <strong>mkpp</strong> <em>(<var>breaks</var>, <var>coefs</var>)</em></dt>
<dt><a name="index-mkpp-1"></a><em><var>pp</var> =</em> <strong>mkpp</strong> <em>(<var>breaks</var>, <var>coefs</var>, <var>d</var>)</em></dt>
<dd>
<p>Construct a piecewise polynomial (pp) structure from sample points
<var>breaks</var> and coefficients <var>coefs</var>.
</p>
<p><var>breaks</var> must be a vector of strictly increasing values.  The number of
intervals is given by <code><var>ni</var> = length (<var>breaks</var>) - 1</code>.
</p>
<p>When <var>m</var> is the polynomial order <var>coefs</var> must be of size:
<var>ni</var><span class="nolinebreak">-by-(</span><var>m</var>&nbsp;+&nbsp;1)<!-- /@w -->.
</p>
<p>The i-th row of <var>coefs</var>, <code><var>coefs</var>(<var>i</var>,:)</code>, contains the
coefficients for the polynomial over the <var>i</var>-th interval, ordered from
highest (<var>m</var>) to lowest (<var>0</var>) degree.
</p>
<p><var>coefs</var> may also be a multi-dimensional array, specifying a
vector-valued or array-valued polynomial.  In that case the polynomial
order <var>m</var> is defined by the length of the last dimension of <var>coefs</var>.
The size of first dimension(s) are given by the scalar or vector <var>d</var>.
If <var>d</var> is not given it is set to <code>1</code>.  In this case
<code><var>p</var>(<var>r</var>, <var>i</var>, :)</code> contains the coefficients for the
<var>r</var>-th polynomial defined on interval <var>i</var>.  In any case <var>coefs</var>
is reshaped to a 2-D matrix of size <code>[<var>ni</var>*prod(<var>d</var>) <var>m</var>]</code>.
</p>
<p>Programming Note: <code>ppval</code> evaluates polynomials at
<code><var>xi</var> - <var>breaks</var>(i)</code>, i.e., it subtracts the lower endpoint of
the current interval from <var>xi</var>.  This must be taken into account when
creating piecewise polynomials objects with <code>mkpp</code>.
</p>
<p><strong>See also:</strong> <a href="#XREFunmkpp">unmkpp</a>, <a href="#XREFppval">ppval</a>, <a href="One_002ddimensional-Interpolation.html#XREFspline">spline</a>, <a href="Signal-Processing.html#XREFpchip">pchip</a>, <a href="#XREFppder">ppder</a>, <a href="#XREFppint">ppint</a>, <a href="#XREFppjumps">ppjumps</a>.
</p></dd></dl>


<a name="XREFunmkpp"></a><dl>
<dt><a name="index-unmkpp"></a><em>[<var>x</var>, <var>p</var>, <var>n</var>, <var>k</var>, <var>d</var>] =</em> <strong>unmkpp</strong> <em>(<var>pp</var>)</em></dt>
<dd>
<p>Extract the components of a piecewise polynomial structure <var>pp</var>.
</p>
<p>This function is the inverse of <code>mkpp</code>: it extracts the inputs to
<code>mkpp</code> needed to create the piecewise polynomial structure <var>PP</var>.
The code below makes this relation explicit:
</p>
<div class="example">
<pre class="example">[breaks, coefs, numinter, order, dim] = unmkpp (pp);
pp2  = mkpp (breaks, coefs, dim);
</pre></div>

<p>The piecewise polynomial structure <code>pp2</code> obtained in this way, is
identical to the original <code>pp</code>.  The same can be obtained by directly
accessing the fields of the structure <code>pp</code>.
</p>
<p>The components are:
</p>
<dl compact="compact">
<dt><var>x</var></dt>
<dd><p>Sample points or breaks.
</p>
</dd>
<dt><var>p</var></dt>
<dd><p>Polynomial coefficients for points in sample interval.
<code><var>p</var>(<var>i</var>, :)</code> contains the coefficients for the polynomial
over interval <var>i</var> ordered from highest to lowest degree.
If <code><var>d</var> &gt; 1</code>, then <var>p</var> is a matrix of size
<code>[<var>n</var>*prod(<var>d</var>) <var>m</var>]</code>, where the
<code><var>i</var> + (1:<var>d</var>)</code> rows are the coefficients of all the <var>d</var>
polynomials in the interval <var>i</var>.
</p>
</dd>
<dt><var>n</var></dt>
<dd><p>Number of polynomial pieces or intervals,
<code><var>n</var> = length (<var>x</var>) - 1</code>.
</p>
</dd>
<dt><var>k</var></dt>
<dd><p>Order of the polynomial plus 1.
</p>
</dd>
<dt><var>d</var></dt>
<dd><p>Number of polynomials defined for each interval.
</p></dd>
</dl>


<p><strong>See also:</strong> <a href="#XREFmkpp">mkpp</a>, <a href="#XREFppval">ppval</a>, <a href="One_002ddimensional-Interpolation.html#XREFspline">spline</a>, <a href="Signal-Processing.html#XREFpchip">pchip</a>.
</p></dd></dl>


<a name="XREFppval"></a><dl>
<dt><a name="index-ppval"></a><em><var>yi</var> =</em> <strong>ppval</strong> <em>(<var>pp</var>, <var>xi</var>)</em></dt>
<dd><p>Evaluate the piecewise polynomial structure <var>pp</var> at the points <var>xi</var>.
</p>
<p>If <var>pp</var> describes a scalar polynomial function, the result is an array
of the same shape as <var>xi</var>.  Otherwise, the size of the result is
<code>[pp.dim, length(<var>xi</var>)]</code> if <var>xi</var> is a vector, or
<code>[pp.dim, size(<var>xi</var>)]</code> if it is a multi-dimensional array.
</p>
<p><strong>See also:</strong> <a href="#XREFmkpp">mkpp</a>, <a href="#XREFunmkpp">unmkpp</a>, <a href="One_002ddimensional-Interpolation.html#XREFspline">spline</a>, <a href="Signal-Processing.html#XREFpchip">pchip</a>.
</p></dd></dl>


<a name="XREFppder"></a><dl>
<dt><a name="index-ppder"></a><em>ppd =</em> <strong>ppder</strong> <em>(pp)</em></dt>
<dt><a name="index-ppder-1"></a><em>ppd =</em> <strong>ppder</strong> <em>(pp, m)</em></dt>
<dd><p>Compute the piecewise <var>m</var>-th derivative of a piecewise polynomial
struct <var>pp</var>.
</p>
<p>If <var>m</var> is omitted the first derivative is calculated.
</p>
<p><strong>See also:</strong> <a href="#XREFmkpp">mkpp</a>, <a href="#XREFppval">ppval</a>, <a href="#XREFppint">ppint</a>.
</p></dd></dl>


<a name="XREFppint"></a><dl>
<dt><a name="index-ppint"></a><em><var>ppi</var> =</em> <strong>ppint</strong> <em>(<var>pp</var>)</em></dt>
<dt><a name="index-ppint-1"></a><em><var>ppi</var> =</em> <strong>ppint</strong> <em>(<var>pp</var>, <var>c</var>)</em></dt>
<dd><p>Compute the integral of the piecewise polynomial struct <var>pp</var>.
</p>
<p><var>c</var>, if given, is the constant of integration.
</p>
<p><strong>See also:</strong> <a href="#XREFmkpp">mkpp</a>, <a href="#XREFppval">ppval</a>, <a href="#XREFppder">ppder</a>.
</p></dd></dl>


<a name="XREFppjumps"></a><dl>
<dt><a name="index-ppjumps"></a><em><var>jumps</var> =</em> <strong>ppjumps</strong> <em>(<var>pp</var>)</em></dt>
<dd><p>Evaluate the boundary jumps of a piecewise polynomial.
</p>
<p>If there are <em>n</em> intervals, and the dimensionality of <var>pp</var> is
<em>d</em>, the resulting array has dimensions <code>[d, n-1]</code>.
</p>
<p><strong>See also:</strong> <a href="#XREFmkpp">mkpp</a>.
</p></dd></dl>


<hr>
<div class="header">
<p>
Next: <a href="Miscellaneous-Functions.html#Miscellaneous-Functions" accesskey="n" rel="next">Miscellaneous Functions</a>, Previous: <a href="Derivatives-_002f-Integrals-_002f-Transforms.html#Derivatives-_002f-Integrals-_002f-Transforms" accesskey="p" rel="prev">Derivatives / Integrals / Transforms</a>, Up: <a href="Polynomial-Manipulations.html#Polynomial-Manipulations" accesskey="u" rel="up">Polynomial Manipulations</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>