Mercurial > octave-nkf
comparison scripts/polynomial/splinefit.m @ 14551:60ed9260399a
Improve/correct documentation for splinefit.m
* splinefit.m: Clarify and correct documentation.
* doc/interpreter/poly.txi: ditto.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 11 Apr 2012 19:34:53 -0400 |
parents | 8985cbbd2fe4 |
children | cd375519eab0 |
comparison
equal
deleted
inserted
replaced
14550:bc4c574ab3b6 | 14551:60ed9260399a |
---|---|
25 ## | 25 ## |
26 ## The fitted spline is returned as a piece-wise polynomial, @var{pp}, and | 26 ## The fitted spline is returned as a piece-wise polynomial, @var{pp}, and |
27 ## may be evaluated using @code{ppval}. | 27 ## may be evaluated using @code{ppval}. |
28 ## | 28 ## |
29 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@var{x}, @var{y}, @var{p}) | 29 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@var{x}, @var{y}, @var{p}) |
30 ## @var{p} is a positive integer defining the number of linearly spaced | 30 ## @var{p} is a positive integer defining the number of intervals along @var{x}, |
31 ## intervals along @var{x}. @var{p} is the number of intervalas and | 31 ## and @var{p}+1 is the number of breaks. The number of points in each interval |
32 ## @var{p}+1 is the number of breaks. | 32 ## differ by no more than 1. |
33 ## | 33 ## |
34 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "periodic", @var{periodic}) | 34 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "periodic", @var{periodic}) |
35 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "robust", @var{robust}) | 35 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "robust", @var{robust}) |
36 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "beta", @var{beta}) | 36 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "beta", @var{beta}) |
37 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "order", @var{order}) | 37 ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "order", @var{order}) |
51 ## value is @var{beta} = 1/2. Values close to 0 give all data equal | 51 ## value is @var{beta} = 1/2. Values close to 0 give all data equal |
52 ## weighting. Increasing values of @var{beta} reduce the influence of | 52 ## weighting. Increasing values of @var{beta} reduce the influence of |
53 ## outlying data. Values close to unity may cause instability or rank | 53 ## outlying data. Values close to unity may cause instability or rank |
54 ## deficiency. | 54 ## deficiency. |
55 ## | 55 ## |
56 ## @var{order} sets the order polynomials used to construct the spline. | 56 ## The splines are constructed of polynomials with degree @var{order}. |
57 ## The default is a cubic, @var{order}=3. A spline with P pieces has | 57 ## The default is a cubic, @var{order}=3. A spline with P pieces has |
58 ## P+@var{order} degrees of freedom. With periodic boundary conditions | 58 ## P+@var{order} degrees of freedom. With periodic boundary conditions |
59 ## the degrees of freedom are reduced to P. | 59 ## the degrees of freedom are reduced to P. |
60 ## | 60 ## |
61 ## The optional property, @var{constraints}, is a structure specifying | 61 ## The optional property, @var{constaints}, is a structure specifying |
62 ## linear constraints on the fit. The structure has three fields, "xc", | 62 ## linear constraints on the fit. The structure has three fields, "xc", |
63 ## "yc", and "cc". | 63 ## "yc", and "cc". |
64 ## | 64 ## |
65 ## @table @asis | 65 ## @table @asis |
66 ## @item "xc" | 66 ## @item "xc" |
67 ## x-locations of the constraints (vector) with a size identical to @var{x}. | 67 ## Vector of the x-locations of the constraints. |
68 ## @item "yc" | 68 ## @item "yc" |
69 ## Constraining values with a size identical to @var{y}. The default | 69 ## Constaining values at the locations, @var{xc}. |
70 ## is an array of zeros. | 70 ## The default is an array of zeros. |
71 ## @item "cc" | 71 ## @item "cc" |
72 ## Coefficients (matrix). The default is an array of ones. The number of | 72 ## Coefficients (matrix). The default is an array of ones. The number of |
73 ## rows is limited to the order of the piece-wise polynomials, @var{order}. | 73 ## rows is limited to the order of the piece-wise polynomials, @var{order}. |
74 ## @end table | 74 ## @end table |
75 ## | 75 ## |
77 ## @var{order}-1 according to | 77 ## @var{order}-1 according to |
78 ## | 78 ## |
79 ## @example | 79 ## @example |
80 ## @group | 80 ## @group |
81 ## @tex | 81 ## @tex |
82 ## $cc(1,j) \cdot y(x) + cc(2,j) \cdot y\prime(x) + ... = yc(:,\dots,:,j), \quad x = xc(j)$. | 82 ## $cc(1,j) \cdot y(xc(j)) + cc(2,j) \cdot y\prime(xc(j)) + ... = yc(:,\dots,:,j)$. |
83 ## @end tex | 83 ## @end tex |
84 ## @ifnottex | 84 ## @ifnottex |
85 ## cc(1,j) * y(x) + cc(2,j) * y'(x) + ... = yc(:,...,:,j), x = xc(j). | 85 ## cc(1,j) * y(xc(j)) + cc(2,j) * y'(xc(j)) + ... = yc(:,...,:,j). |
86 ## @end ifnottex | 86 ## @end ifnottex |
87 ## @end group | 87 ## @end group |
88 ## @end example | 88 ## @end example |
89 ## | 89 ## |
90 ## @seealso{interp1, unmkpp, ppval, spline, pchip, ppder, ppint, ppjumps} | 90 ## @seealso{interp1, unmkpp, ppval, spline, pchip, ppder, ppint, ppjumps} |
128 %! % Noisy data | 128 %! % Noisy data |
129 %! x = linspace (0, 2*pi, 100); | 129 %! x = linspace (0, 2*pi, 100); |
130 %! y = sin (x) + 0.1 * randn (size (x)); | 130 %! y = sin (x) + 0.1 * randn (size (x)); |
131 %! % Breaks | 131 %! % Breaks |
132 %! breaks = [0:5, 2*pi]; | 132 %! breaks = [0:5, 2*pi]; |
133 %! % Constraints: y(0) = 0, y"(0) = 1 and y(3) + y"(3) = 0 | 133 %! % Constraints: y(0) = 0, y'(0) = 1 and y(3) + y"(3) = 0 |
134 %! xc = [0 0 3]; | 134 %! xc = [0 0 3]; |
135 %! yc = [0 1 0]; | 135 %! yc = [0 1 0]; |
136 %! cc = [1 0 1; 0 1 0; 0 0 1]; | 136 %! cc = [1 0 1; 0 1 0; 0 0 1]; |
137 %! con = struct ("xc", xc, "yc", yc, "cc", cc); | 137 %! con = struct ("xc", xc, "yc", yc, "cc", cc); |
138 %! % Fit a cubic spline with 8 pieces and constraints | 138 %! % Fit a cubic spline with 8 pieces and constraints |