Most of the data fit functions accept two or
three vectors of data : x, y (the points to fit) and often the optional
weights w for the points.
The data can either be specified as separate vectors or as a single
n x 2 or n x 3 matrix.
Referring with D to the data points either with weights or not,
we can have one of the following cases:
D=x,y or D={x | y}
D=x,y,w or D={x | y | w}
|
Function |
Description |
PolyFit |
PolyFit(x,y,w,n,m,s)
or
PolyFit({x | y | w}, n, m,s)
Computes the coefficients of the nth degree polynomial which
best fits the given points.
x,y are the coordinates of the points
w is an optional column with the weights of the points
n is the desired polynomial degree
m (0 - 7) is the method to solve the linear system (for m
> 1 needs SolveLinearSystem from Linear Algebra Package)
s (0 or 1) input data have to be normalized (1) or not (0,
default).
Normalization means v=(v-avg(v))/std(v) for both x and y.
Weights are ignored for normalization. |
PolyVal
|
PolyVal(coeffs,x)
Evaluates the polynomial whose coefficients are in coeffs
at the values in x using the Horner's Rule.
To evaluate ax^2+bx+c at
x = 1 and x = 7 use
PolyVal({a,b,c},{1,7}) |
FuncFit |
FuncFit(x,y,w,flist)
or
FuncFit({x | y | w}, flist)
Computes the coefficients for the linear combination of the functions
listed in flist which best fits the points specified in
x and y.
w is optional and contains the weights for the points.
The functions must be declared in the workspace and their names
must be 2 chars long. They must use the V: vector syntax.
flist is a string containing the names of the functions separated
by commas like "fa(),fb(),fc()" |
FuncVal |
FuncVal(coeffs,funclist,x)
Evluates the linear combination of the functions specified in
flist with the coefficients in coeffs for the values
in x.
coeffs must be a vector
flist is a string like "fa(),fb(),fc()" where the functions
must be declared in the workspace and have a 2 chars name.
They must use the V: syntax.
x can be a scalar or a vector |
SplineFit |
SplineFit(xInp, yInp, LCond, RCond, {LDer,RDer})
or
SplineFit(m, LCond,RCond, {LDer,RDer})
where
xInp and yInp or m={xInp,yInp} are the input
points.
LCond,RCond are the conditions at Left and Right endpoints
:
0 = natural
1 = clamped
2 = quadratic runout
3 = cubic runout (aka not-a-knot)
4 = periodic
{LDer,RDer} are the values of the slope at the endpoints
for the clamped condition. Both values must be given even if only
one is actually used.
Computes the curvatures at the given points of the cubic spline
interpolating them. If plotted plots the points and the interpolating
spline
Note : for the spline fitting the points cannot have weights,
since the curve already passes through all the given poins.
Reference:
Jaan Kiuslaas - Numerical Methods in Engineering with Matlab™ -
Cambridge University Press 2005 - Paragraph 3.3 |
SplineEval |
SplineEval(xInp,yInp,k,x)
or
SplineEval(m,k,x)
where
xInp,yInp or m={xInp,yInp} are the input data points
k is a vector containing the spline curvatures at the input
data points
x = is a vector of x values
Returns the Cubic Spline value(s) in the point(s) x
Reference:
Jaan Kiuslaas - Numerical Methods in Engineering with Matlab™ -
Cambridge University Press 2005 - Paragraph 3.3 |
CorrCoeff |
CorrCoeff(y1,y2,w)
or
CorrCoeff({y1 | y2 | w})
Returns the correlation coefficient for two optionally weighted
datasets.
A second coefficient is always computed ignoring the weights.
y1 = 1st set of y values
y2 = 2nd set of y values
w = optional weights |
NormProbPlot |
NormProbPlot(y1,y2,w)
Computes the Least Squares Linear Fit for the Normal Probability
Plot of the given points.
If plotted plots the plot itself and the regression line.
A high correlation coefficient gives a reasonable confidence on
the normality of the points distribution.
If only one set of y is given the plot is computed on them.
If y1 and y2 are given, the plot is computed on
y2-y1 (residuals). If also w is given the plot is computed
on (y2-y1)*w
In the use with data fitting, a good (e.g. linear) normal probability
plot of the residuals from the given and computed points is considered
a index of a good fit. |
|