Syntax
[C/C++:]
void ggReturnLineCoeffs(int type, int npts, GPOINT *points, int ncoef, float coeffs[ ], int *nmax, int *er);
[F90:]
subroutine ggReturnLineCoeffs(type, npts, points, ncoef, coeffs, nmax, er)
integer, intent(in) :: type, npts, ncoef
integer, intent(out) :: nmax, er
type(GPOINT), intent(in) :: points(*)
real, intent(out) :: coeffs(*)
Arguments
type
Type of line fitting performed on the data set
|
= GLEASTSQUARE |
Least squares straight line fit |
|
> 1 |
Reserved for future use |
points
Array of dimension
npts, giving the X and Y axis values of the points defined on the graph
npts
The number of points in X and Y
ncoef
The number of coefficients required to be returned
coeffs
Array of dimension
ncoef, returning the coefficients of the fitted line
nmax
The total number of coefficients of the fitted line
|
= 0, |
No coefficients returned due to argument or fitting error |
|
> 0, |
Number of coefficients of successful fit |
er
Error flag
|
= GSUCCESS |
Successful fit |
Description
The routine ggReturnLineCoeffs() takes a set of data points and fits a straight line or curve to it, returning their coefficients to the user. No graphics output is generated by this routine.
The data is supplied in the components
points.x,
points.y each having
npts points. The coefficients are returned in the array
coeffs which should have the same dimension as the number of coefficients required as set in
ncoef. The actual number of coefficients calculated by the fitting algorithm is returned in
nmax which may be more or less than
ncoef.
In the case of the straight line fit (
type=GLEASTSQUARE), the two coefficients 'a' and 'b' of line 'y=ax + b' are returned in
coeffs(2) and
coeffs(1) respectively.
If less than two points are supplied or less that one coefficient is requested, an error message is generated and no fitting is attempted. If there is enough data but a fit is not possible (ie, if the points are located in one position, or if all the points have the same Y coordinate values) the error flag
er is set to 1 but no error message is produced. In either of these cases
nmax is set to zero to indicate that no coefficients have been returned.
See Also
ggReturnLineCoeffs Usage