Curve fitting with error bars, Matlab

2.1k views Asked by At

I have some measurements in Matlab that I wanna use to fit a exponential curve. To this measurements I have different uncertainty. How do I fit a exponential curve with this uncertainty balanced?

1

There are 1 answers

0
hello123 On

Let´s generate exponential data, “with different uncertainty”:

x=0:0.1:5; 
k=randn(1,length(x))*4;
Measurement_data=exp(x)+k;

Fit data to a single exponential, where f is the fitting model:

f = fit(x',Measurement_data','exp1')

Plot measurement data and fitting curve:

plot(x,Measurement_data,'.');
hold on
plot(x,f.a*exp(f.b*x));

Plot data and model

In this case, fitting model f is:

     General model Exp1:
     f(x) = a*exp(b*x)
     Coefficients (with 95% confidence bounds):
       a =      0.8414  (0.6367, 1.046)
       b =       1.034  (0.9805, 1.087)

Hope this solves your problem.