Method ao/polyfit


  POLYFIT overloads polyfit() function of MATLAB for Analysis Objects.
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  DESCRIPTION: POLYFIT overloads polyfit() function of MATLAB for Analysis
               Objects. It finds the coefficients of a polynomial P(X) of
               degree N that fits the data Y best in a least-squares sense:
               P(1)*X^N + P(2)*X^(N-1) +...+ P(N)*X + P(N+1)
 
  CALL:        bs = polyfit(a1, a2, a3, ..., pl)
               bs = polyfit(as,pl)
               bs = as.polyfit(pl)
 
  INPUTS:      aN   - input analysis objects with data to be fitted.
                    X will be a.x
                    Y will be a.y
               as   - input analysis objects array
               pl   - input parameter list
 
  OUTPUTs:     bs  - An array of pest objects, each with the N+1 fitting coefficients P(j)
 
  Parameters Description
 
  EXAMPLES:
  
    %% Make fake AO from polyval
    nsecs = 100;
    fs    = 10;
    
    u = unit('fm s^-2');
    
    pl = plist('nsecs', nsecs, 'fs', fs, ...
      'tsfcn', 'polyval([3 2 1 ], t) + 1000*randn(size(t))', ...
      'xunits', 's', 'yunits', u);
  
    a1 = ao(pl);
    
    %% Fit a polynomial
    N = 3;
    p1 = polyfit(a1, plist('N', N));
    p2 = polyfit(a1, plist('N', N, 'rescale', true));
 
    %% Compute fit: evaluating pest
    %% Here we need to specify that we want to use the 'x' field of 
    %% the AO a to build the output AO
    
    b1 = p1.eval(plist('type', 'tsdata', 'XData', a1, 'Xfield', 'x'));
    b2 = p2.eval(a1, plist('type', 'tsdata', 'Xfield', 'x'));
    
    %% Plot fit
    iplot(a1, b1, plist('LineStyles', {'', '--'}));
 
    %% Remove polynomial
    c = a1-b1;
    iplot(c)
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Method Details
Access public
Defining Class ao
Sealed 0
Static 0

Parameter Description

Default

no description
Key Default Value Options Description
N, ORDER 1
  • 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
Degree of polynomial to fit.
RESCALE 0
  • 0
  • 1
set to 'true' or 'false' to center and rescale the data before fitting.
See "help polyfit" for further details.
back to top back to top

Some information of the method ao/polyfit are listed below:
Class name ao
Method name polyfit
Category Signal Processing
Package name ltpda
VCS Version 3542afe99dea25c636b7ac3b82a9f6f8be9d447d
Min input args 1
Max input args -1
Min output args 1
Max output args -1




©LTP Team