function [F1, F2, F3, F4]= fitje(x,y,i0,i1)
%FITJE  calculates the functions which are fitted throug the obs scatter
%data.
%
%fitje uses the Curve Fitting Toolbox from MATLAB
%
%   [D1,D2,D3,D4]=FITJE(A.depth,A.OBS,start,end)
%
% This function can be used to look whether the scatter from the obs relate to a certain function:
%
%
%See also: SILTPROFILER_READ_ASC; SILTPROFILER_PLOT_FITTED_OBS; CFTOOL
%SILTPROFILER_PLOT
%% INPUT
 l  =  x(i1).*-1+1.001;
 x  =  x(i0:i1).*-1;
 k  =  y(i0);
 y  =  y(i0:i1)';
 
 %% Functions
 F1 =  fit(x,y,'exp2');
 D  =  coeffvalues(F1);

 curve  = fittype('a.*((x./b).*c./(d - x)).^f + g.*exp(h.*x)','coeff',{'a','b','c','d','f','g','h'});
 curve2 = fittype('a.*((x./b).*c./(d - x)).^f','coeff',{'a','b','c','d','f'});
 curve3 = fittype('a.*exp(b.*x)+c.*exp(d.*x)+f.*exp((g-l).*x)','coeff',{'a','b','c','d','f','g','l'});
 
 F2     = fit(x,y,curve, 'Lower',[1 0 0 l -1 -1 -1],...
                         'Upper',[ 40 40 40 40 1 20 10],...
                         'StartPoint',[k 0.1 12 l 0 D(3) D(4)],...
                         'MaxFunEvals',2000);
 F3     = fit(x,y,curve2,'Lower',[1 0 0 l -1],...
                         'Upper',[ 40 40 40 40 1],...
                         'StartPoint',[k 0.1 12 l 0],...
                         'MaxFunEvals',2000);
 F4     = fit(x,y,curve3,'Lower',[-100 -100 -100 -100 -100 -100 l],...
                         'Upper',[40 40 40 40 40 40 40],...
                         'StartPoint',[D(1) D(2) D(3) D(4) 0 0 l],...
                         'MaxFunEvals',2000);
% F5    = fit(x,y,'exp1','StartPoint',[0 0]); 
 
 clear D
 clear x
 clear y
 
