function [a, b] = expfit (x, y)
%EXPFIT    Exponential fit.
%          [a,b] = expfit(x,y) fits x and y to exponential a*exp(b*x) with
%          no constraints.
%          Internaly uses EXPFIT_x and EXPFIT_y global variables.

% Copyright (c) 1994 by Bogdan R. Kosanovic
% University of Pittsburgh, PA, USA

% History: 07-Apr-94 Created

global EXPFIT_x
global EXPFIT_y   % actual data

EXPFIT_x = x(:); EXPFIT_y = y(:);

ab0 = [y(1); 0];   % parameters a and b

options = foptions;
options(1) = 1;   % display each optimization cycle
options(3) = 1e-4;

ab = fminu('expf', ab0);
a = ab(1); b = ab(2);
