Method ao/polynomfit


  POLYNOMFIT is a polynomial fitting tool
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  DESCRIPTION: POLYNOMFIT is a polynomial fitting tool based on MATLAB's
  lscov function. It solves an equation in the form
 
      Y = P(1) * X^N(1) + P(2) * X^N(2) + ...
 
  for the fit parameters P. It handles arbitrary powers of the input vector
  and uncertainties on the dependent vector Y and input vectors X.
  The output is a pest object where the fields are containing:
  Quantity                              % Field
  Fit coefficients                          y
  Uncertainties on the fit parameters
  (given as standard deviations)            dy
  The reduced CHI2 of the fit              chi2
  The covariance matrix                    cov
  The degrees of freedom of the fit        dof
 
  CALL:       P = polynomfit(X, Y, PL)
              P = polynomfit(A, PL)
 
  INPUTS:     Y   - dependent variable
              X   - input variables
              A   - data ao whose x and y fields are used in the fit
              PL  - parameter list
 
  OUTPUT:     P   - a pest object with M = numel(N) fitting coefficients
 
 
  PARAMETERS:
     'orders' - polynom orders. Eg [0,1,-2] fits to P0 + P1*x + P2./x.^2
     'dy'     - uncertainty on the dependent variable
     'dx'     - uncertainties on the input variable
     'p0'     - initial guess on the fit parameters used ONLY to propagate
                uncertainities in the input variable X to the dependent variable Y
 
  Parameters Description
 
  EXAMPLES:
 
  % 1) Fit with one object input
 
  nsecs = 5;
  fs    = 10;
  n       = [0 1 -2];
  u1 = unit('mV');
 
  pl1 = plist('nsecs', nsecs, 'fs', fs, ...
    'tsfcn', sprintf('t.^%d + t.^%d + t.^%d + randn(size(t))', n), ...
    'xunits', 's', 'yunits', u1);
  a1 = ao(pl1);
  out1 = polynomfit(a1, plist('orders', n, 'dx', 0.1, 'dy', 0.1, 'P0', zeros(size(n))));
 
  % 2) Fit with two objects input
 
  fs      =  1;
  nsecs   = 10;
  n       = [0 1 -2];
 
  X = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm', 'name', 'base'));
  N = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs, 'yunits', 'm', 'name', 'noise'));
  C = [ao(1, plist('yunits', 'm', 'name', 'C1')) ...
       ao(4, plist('yunits', 'm/m', 'name', 'C2')) ...
       ao(2, plist('yunits', 'm/m^(-2)', 'name', 'C3'))];
  Y = C(1) * X.^0 + C(2) * X.^1 + C(3) * X.^(-2) + N;
  Y.simplifyYunits;
  out2 = polynomfit(X, Y, plist('orders', n))
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Method Details
Access public
Defining Class ao
Sealed 0
Static 0

Parameter Description

Default

no description
Key Default Value Options Description
polynomfit
ORDERS 0 none Polynom orders.
DY [] none Uncertainty on Y. Can be expressed as
  • an AO with single value or
  • an AO with a vector of the right length or
  • a double or
  • an array of double of the right length
DX [] none Uncertainty on X(1..N). Can be expressed as
  • an AO with single value or
  • an AO with a vector of the right length or
  • a double or
  • an array of double of the right length
P0 [] none Initial guess of the fit parameters. Can be expressed as:
  • an AOs with a vector
  • an array of scalars or
  • a pest object

Example

plist('ORDERS', [0], 'DY', [[]], 'DX', [[]], 'P0', [[]])

back to top back to top

Some information of the method ao/polynomfit are listed below:
Class name ao
Method name polynomfit
Category Signal Processing
Package name ltpda
VCS Version 967b0eec0dece803a81af8ef54ad2f8c784b20b2
Min input args 1
Max input args -1
Min output args 1
Max output args -1
Can be used as modifier 0
Supported numeric types {'double'}




©LTP Team