CLsqFit:GetPtX
The GetPtX method returns the values of the independent variables for an existing sample point. The value(s) are returned in a 1-dimensional array. The related GetPt method returns both the independent and dependent variables for a point.
tblX = CLsqFit:GetPtX( nIndex ) tblX = CLsqFit:GetPtX( nIndex, nDimension ) |
nIndex is the index of the point in the sample, beginning at index 1.
nDimension is an optional parameter that specifies the basis dimension (index of the independent variable) when the fit involves more than 1 basis dimension.
tblX is a 1-dimensional array holding values of the independent variable(s).
This method returns the x value or values in a 1-dimensional array even if the fit uses only 1 independent variable, or "basis dimension". The values at different basis dimensions are accessed as elements 1, 2, and so on. The number of elements in the table equals the number of basis dimensions used in the fit. Since Mira supports up to 10 dimensions, the table may caontain 1 to 10 elements. The number of table elements may be obtained using the # operator, like #tbl, or by calling the GetBasisDim method.
The GetPtX method uses the index of the target point. The value of nIndex must either be known from the order that points were added to the sample, or by matching the target point's values using FindPt.
The following example illustrates how to change the x coordinate of an existing point. The target point's index is found by matching its values:
|
-- create a CLsqFit object |
|
-- set 2 coefficients |
|
-- add a point for x = 3.5, y = 5.15, weight = 1 |
-- add more points to the fit |
|
|
-- Fit the line |
-- do something with the fit results |
|
|
-- find the point (if we don't know it was index 1) |
|
-- coordinate(s) returned in array t |
|
-- add 0.1 to the first index of the table (x coordinate) |
|
-- send the table to replace the 1st coordinate value |
|
-- get a new fit result using the new value |
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.