
x=[0 1 2 4 6 8 10];
y=[0 -106.693270000000 -206.664010000000 -348.174410000000 ...
    -403.579730000000 -621.608620000000 -495.334410000000];
f_ = clf;
figure(f_);
 set(f_,'Units','Pixels','Position',[445 242 688 486]);
 legh_ = []; legt_ = {};   % handles and text for legend
 xlim_ = [Inf -Inf];       % limits of x axis
ax_ = axes;
set(ax_,'Units','normalized','OuterPosition',[0 0 1 1]);
set(ax_,'Box','on');
axes(ax_); 
hold on;

% --- Plot data originally in dataset "Ablationstiefe vs. Pulsanzahl Messreihe 1"
x = x(:)
y = y(:)
h_ = line(x,y,'Parent',ax_,'Color',[1 0 0],...
    'LineStyle','none', 'LineWidth',2,...
    'Marker','square', 'MarkerSize',6);
 xlim_(1) = min(xlim_(1),min(x));
 xlim_(2) = max(xlim_(2),max(x));
 legh_(end+1) = h_;
legt_{end+1} = 'original Werte';


% --- Create fit "Exponential (Robust: LAR, Algo: Trust-Region)"
fo_ = fitoptions('method','NonlinearLeastSquares','Robust','LAR',...
    'MaxFunEvals',10000,'MaxIter',10000);
ok_ = isfinite(x) & isfinite(y);
if ~all( ok_ )
    warning( 'GenerateMFile:IgnoringNansAndInfs', ...
        'Ignoring NaNs and Infs in data' );
end
st_ = [-382.24438889714349 -0.047351984769528989 0 -0.047351984769528989 ];
set(fo_,'Startpoint',st_);
cflibhelp exponential
ft_ = fittype('exp2');
%ft_ = fittype({'a*exp(b*x)+c*exp(d*x)'},'coefficients',{'a','c'})
%ft_ = fittype('a*exp(b*x)+c*exp(d*x)');


% Fit this model using new data
%cf_ = cfit(Pulsanzahl(ok_),Abaltionstiefe(ok_),ft_,fo_);

[cf_,gof,output] = fit(x(ok_),y(ok_),ft_,fo_)
coeffnames(cf_)
coeffvalues(cf_)
probnames(cf_)
probvalues(cf_)


% Plot this fit
h_ = plot(cf_);
legend off;  % turn off legend from plot method call
set(h_(1),'Color',[0.666667 0.333333 0],...
    'LineStyle','-', 'LineWidth',2,...
    'Marker','none', 'MarkerSize',6);
legh_(end+1) = h_(1);
legt_{end+1} = 'Exponential (Robust: LAR, Algo: Trust-Region)';

% Done plotting data and fits.  Now finish up loose ends.
hold off;
leginfo_ = {'Orientation', 'vertical', 'Location', 'NorthEast'};
h_ = legend(ax_,legh_,legt_,leginfo_{:});  % create legend
set(h_,'Interpreter','none');
xlabel(ax_,'x');              
ylabel(ax_,'y');          
