CLsqFit:GetX


The GetX method returns a 1-dimensional array containing the independent variable ("x") values for the n-th basis dimension, starting at 1. For example, if fitting one variable (that is, 1 basis dimension. or y(x)), then you do not need to specify the dimension. The returned table contains CLsqFit:GetNumPts() values.

Syntax

tX = CLsqFit:GetX()

tX = CLsqFit:GetX( nDim )

tX1, tX2, tX, tWt4 = CLsqFit:GetX()

bullet.gif    nDim is the basis dimension to return, starting at 1. If only one dimension is dit, as in fitting the "x" value, then this parameter can be omitted.

bullet.gif    tX is a 1-dimensional array containing the values of all points for the n-th dimension.

bullet.gif    tX1, tX2, tX3, etc.are tables of all X values for every basis dimension. The number of tables returned equals the number of dimensions being fit. Each

Example

The following example shows how to fit a 2x3 polynomial to (x,y,z) data, then makes a scatter plot of the observed values against the y value (dimension 2) :

L = new_lsqfit()

-- create a CLsqFit object

L:SetNumCoefs( 2, 3 )

-- Fit a 2-D polynomial with 2x3 coefficients

L:AddPt( 3.1, 4.65, 12.5 )

-- add a point for x = 3.2, y = 4.65, z = 12.5

-- add more points to the fit

 

L:Fit()

-- Fit the polynomial

scatter( L:GetX( 2 ), L:GetObs() )

-- make a scatter plot of observed value against X[2]

Related Topics

CLsqFit class, GetPtX, GetObs


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