Laura
Laura

Reputation: 89

Matlab fitting error using lsqcurvefit

I'm developing code to fit the Gompertz equation to a bacterial growth curve and am practicing with some example data provided at the following website:

http://www.math.tamu.edu/~phoward/m442/ia3sol.pdf.

According to this code the fit should almost match the data (graph given at above webpage, page 3). However when I run the code the actual data plots correctly but the lsqcurve fit fits very poorly and gives the following message:

Local minimum possible.

lsqcurvefit stopped because the size of the current step is less than
the default value of the step size tolerance.

Is there anything I am doing wrong?

Thank you for your time,

Laura

Upvotes: 0

Views: 701

Answers (1)

rozsasarpi
rozsasarpi

Reputation: 1641

The problem lies in the linked document.

The Gompertz function is parametrized the following way:

%with parameters p(1) = K and p(2) = initial population
%p(3) = r.
V = p(1).*(p(2)/p(1)).^exp(-p(3)*t);

However, the initial parameters for the curve fitting are given for a different ordering of parameters in p vector ([r, K, p0] instead of [K, p0, r]). Moreover, the result vector is also messed up in the document.

By changing p0 to this [1000, 3.93, 0.01] the curve fitting will converge and you will get a nice fit:

Upvotes: 1

Related Questions