Home > freetb4matlab > optim > expfit.m

# expfit

## PURPOSE

% USAGE [alpha,c,rms] = expfit( deg, x1, h, y )

## SYNOPSIS

function [a,c,rms] = expfit(deg,x1,h,y)

## DESCRIPTION

% USAGE  [alpha,c,rms] = expfit( deg, x1, h, y )
%
% Prony's method for non-linear exponential fitting
%
% Fit function:   \sum_1^{deg} c(i)*exp(alpha(i)*x)
%
% Elements of data vector y must correspond to
% equidistant x-values starting at x1 with stepsize h
%
% The method is fully compatible with complex linear
% coefficients c, complex nonlinear coefficients alpha
% and complex input arguments y, x1, non-zero h .
% Fit-order deg  must be a real positive integer.
%
% Returns linear coefficients c, nonlinear coefficients
% alpha and root mean square error rms. This method is
% known to be more stable than 'brute-force' non-linear
% least squares fitting.
%
% Example
%    x0 = 0; step = 0.05; xend = 5; x = x0:step:xend;
%    y = 2*exp(1.3*x)-0.5*exp(2*x);
%    error = (rand(1,length(y))-0.5)*1e-4;
%    [alpha,c,rms] = expfit(2,x0,step,y+error)
%
%  alpha =
%    2.0000
%    1.3000
%  c =
%    -0.50000
%     2.00000
%  rms = 0.00028461
%
% The fit is very sensitive to the number of data points.
% It doesn't perform very well for small data sets.
% Theoretically, you need at least 2*deg data points, but
% if there are errors on the data, you certainly need more.
%
% Be aware that this is a very (very,very) ill-posed problem.
% By the way, this algorithm relies heavily on computing the
% roots of a polynomial. I used 'roots.m', if there is
% something better please use that code.
%

## CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:
• expdemo % An example of expfit in action

Generated on Sat 16-May-2009 00:04:49 by m2html © 2003