Spline Toolbox | ![]() ![]() |
Put together a spline in B-form
Syntax
Description
The command spmak(...)
puts together a spline function in B-form, from minimal information, with the rest inferred from the input. fnbrk
returns all the parts of the completed description. In this way, the actual data structure used for the storage of this form is easily modified without any effect on the various fn...
commands that use this construct.
spmak(knots,coefs)
returns the B-form of the spline specified by the knot information in knots and the coefficient information in coefs.
The action taken by spmak
depends on whether the function is univariate or multivariate, as indicated by knots
being a sequence or a cell array.
If knots
is a sequence (required to be non-decreasing), then the spline is taken to be univariate, and its order is taken to be length(knots)-size(coefs,2)
. This means that each column of coefs
is taken to be a B-spline coefficient of the spline. This follows the general agreement in this toolbox that, in case of a vector-valued spline, any vector in its target, be it a coefficient, or the value of the spline at a site, is written as a 1-column matrix. In particular, the spline is d
-vector-valued, with d
equal to size(coefs,1)
. Finally, the basic interval of the B-form is [knots(1)
.. knots(end)
].
Knot multiplicity is held to be
k
. This means that the coefficient coefs(:,j)
is simply ignored in case the corresponding B-spline has only one distinct knot, i.e., in case knots(j)
equals knots(j+k)
.
If knots
is a cell array, of length m
, then the spline is taken to be m
-variate, and coefs
must be an (m
+1)-dimensional array, - except when the spline is to be scalar-valued, in which case, in contrast to the univariate case, coefs
is permitted to be an m
-dimensional array, but this array is immediately reshaped by
With this, the i
th entry of m
-vector k
is computed as length(knots{i})
- size(coef,i+1)
, i=1:m
, and the i
th entry of the cell array of basic intervals is set to [knots{i}(1), knots{i}(end)]
.
spmak(knots,coefs,sizec)
lets you supply the intended size of the array coefs
. Assuming that coefs
is correctly sized, this is of concern only in the rare case that coefs
has one or more trailing singleton dimensions. For, MATLAB suppresses trailing singleton dimensions, hence, without this explicit specification of the intended size of coefs
, spmak
would interpret coefs
incorrectly.
spmak
prompts you for knots
and coefs
.
Examples
spmak([1:6],[0:2])
constructs a spline function with basic interval [1. .6], with 6 knots and 3 coefficients, hence of order 6 - 3 = 3.
spmak(t,1)
provides the B-spline in B-form.
The coefficients may be d
-vectors (e.g., 2-vectors or 3-vectors), in which case the resulting spline is a curve or surface (in R2 or R3).
If the intent is to construct a 2-vector-valued bivariate polynomial on the rectangle , linear in the first variable and constant in the second, say
will result in the error message `There should be no more knots than coefficients
', because the trailing singleton dimension of coefs
will not be perceived by spmak
, while proper use of that third argument, as in
will succeed. Replacing here [2 2 1]
by size(coefs)
would not work.
See spalldem
for other examples.
See Also
Diagnostics
There will be an error return if the proposed knot sequence fails to be nondecreasing, or if the coefficient array is empty, or if there are not more knots than there are coefficients. If the spline is to be multivariate, then this last diagnostic may be due to trailing singleton dimensions in coefs
.
![]() | splpp, sprpp | stcol | ![]() |