CLsqFit:SetPtX


The SetPtX method sets a new value for the coordinate values of an existing data point. If the point has more than 1 dimension, you can pass all coordinates as a 1-dimensional array or pass one value to set in the specified dimension.

Syntax

CLsqFit:SetPtX( nIndex, nX )

CLsqFit:SetPtX( nIndex, nX, nDimension )

CLsqFit:SetPtX( nIndex, tblX )

bullet.gif    nIndex is the index of the point in the sample, beginning at index 1.

bullet.gif    nX is the new value of the independent variable.

bullet.gif    tblX is a 1-dimensional array containing values for all the independent variables. The number of coordinate values (independent variables) inthe table must match the dimensions of the fit specified using the SetNumCoefs method.

bullet.gif    nDimension is an optional parameter that specifies the target dimension (index of the independent variable) when the fit involves more than 1 basis dimension.

Remarks

This method can set the value for one or all x values up to the basis dimension (that is, the number of independent variables being fit which has a maximum of 10). To change one specific dimension, or if the basis has only one dimension of independent variable, you can pass either the number nX or the table tableX . If targeting a particular dimension, specify the nDimension argument. To change the values for all dimensions, place the values into the table tableX, and ignore the nDimension argument. Passing a table of coordinates is consistent with the value returned by the GetPtX method.

The SetPtX 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.

Examples

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:

L = new_lsqfit()

-- create a CLsqFit object

L:SetNumCoefs( 2 )

-- set 2 coefficients

L:AddPt( 3.5, 5.15 )

-- add a point for x = 3.5, y = 5.15, weight = 1

-- add more points to the fit

 

L:Fit()

-- Fit the line

-- do something with the fit results

 

n = L:FindPt( 3.5, 5.15 )

-- find the point (if we don't know it was index 1)

t = L:GetPtX(n)

-- coordinate(s) returned in table t

t[1] = t[1] + 0.1

-- add 0.1 to the first index of the table (x coordinate)

L:SetPtX( n, t )

-- send the table to replace the 1st coordinate value

L:Fit()

-- get a new fit result using the new value

Related Topics

CLsqFit class, GetPtX, AddPt, FindPt


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.