fnrfn
Refine partition of form
Syntax
g = fnrfn(f,addpts)
Description
g = fnrfn(f,addpts)
describes the same function as doesf
, but uses more terms to do it. This is of use when the sum of two or more functions of different forms is wanted or when the number of degrees of freedom in the form is to be increased to make fine local changes possible. The precise action depends on the form inf
.
If the form inf
is a B-form or BBform, then the entries ofaddpts
are inserted into the existing knot sequence, subject to the following restriction: The multiplicity of no knot exceed the order of the spline. The equivalent B-form with this refined knot sequence for the function given byf
is returned.
If the form inf
is a ppform, then the entries ofaddpts
are inserted into the existing break sequence, subject to the following restriction: The break sequence be strictly increasing. The equivalent ppform with this refined break sequence for the function inf
is returned.
fnrfn
does not work for functions in stform.
If the function inf
is m-variate, thenaddpts
must be a cell array,{addpts1,..., addptsm}
, and the refinement is carried out in each of the variables. If theith entry in this cell array is empty, then the knot or break sequence in theith variable is unchanged.
Examples
Construct a spline in B-form, plot it, then apply two midpoint refinements, and also plot the control polygon of the resulting refined spline, expecting it to be quite close to the spline itself:
k = 4;sp = spapi (k,[1 1:10 10],[因为(1),罪(1:10),cos(10)] ); fnplt(sp), hold on sp3 = fnrfn(fnrfn(sp)); plot( aveknt( fnbrk(sp3,'knots'),k), fnbrk(sp3,'coefs'), 'r') hold off
Usefnrfn
to add two B-splines of the same order:
B1 = spmak([0:4],1); B2 = spmak([2:6],1); B1r = fnrfn(B1,fnbrk(B2,'knots')); B2r = fnrfn(B2,fnbrk(B1,'knots')); B1pB2 = spmak(fnbrk(B1r,'knots'),fnbrk(B1r,'c')+fnbrk(B2r,'c')); fnplt(B1,'r'),hold on, fnplt(B2,'b'), fnplt(B1pB2,'y',2) hold off
Algorithms
The standardknot insertionalgorithm is used for the calculation of the B-form coefficients for the refined knot sequence, while Horner's method is used for the calculation of the local polynomial coefficients at the additional breaks in the refined break sequence.