CLsqFit:GetPt
The GetPt method returns the values of both the independent and dependent variables of a sample point. The value(s) are returned in a 1-dimensional array.
tbl = CLsqFit:GetPt( nIndex ) |
nIndex is the index of the point in the sample, beginning at index 1.
tbl is a 1-dimensional array holding the independent variables plus the dependent variables for the point.
The array has a total dimension of #x for the table x of independent variables, plus #obs for the table obs of dependent variables (observations). For example, if the fitting basis has 3 variables (dimensions) and numerical observations were fit, then the returned table has 3 + 1 = 4 elements. Similarly, if the fitting basis has 2 variables (dimensions) and RGB observations were fit, then the returned table has 2 + 3 = 5 elements.
The number of table elements may be obtained using the # operator, like #t, as shown in the example below. Alternatively, you can get the counts of each using GetBasisDim and GetNumChannels.
The GetPt 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 point's values using FindPt.
The following example illustrates how to get the independent and dependent variables for an existing point. The target point's index is found by matching its coordinates:
|
-- create a CLsqFit object |
|
-- set 2 coefficients |
-- add points to the fit... |
|
-- add another point to the fit: |
|
|
-- 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) |
|
-- point index < 1 means point not found |
|
-- Get the coordinates, returned in array t |
|
-- Get the number of table elements |
-- list all the values for point n |
|
|
|
|
-- list each value of thereturned table |
|
|
-- Alternately, list the table like this: |
|
|
|
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.