fitting logistic growth equation to data
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I'm trying to fit the logistic growth equation to a set of algae growth data I have to calculate the growth rate, r. The data that I'm trying to fit to the equation is cell counts per mL every day for about 20 days. I have some code so far (below) but it isn't working/isn't complete (right now I'm getting some errors which I've copied below all the code) . 'logistic' is the separate script that holds the logistic growth equation, and I've copied that script below the main script. I want to get the best estimate of r using a least-squares technique. Any help would be very much appreciated! Thanks very much!
% Data import
load 'cultures1e3.csv' %load data for culture
global dataT dataN1
dataT = cultures1e3(:,1); %x = time (days)
dataN1 = cultures1e3(:,2); %y = cell count (cells/mL)
%%Curve fitting
% Initial estimates for r
r0 = 0.1;
% Estimate parameters
%fh = @logistic;% Function handle - started with this but eventually went with str2func
fh = str2func('logistic');
tic
pFit = lsqcurvefit(fh , r0, dataT, dataN1) ;
toc
-----logistic() script ----- function logistic() %logistic growth equation for data fitting
global dataT
funcN_init = 1e3;
K = 3.5e6; %estimate of carrying capacity
r = .1; %growth rate --> what I want to estimate
%options
options = [];
% Solver
[dataT funcN] = ode45(@odefun, dataT, funcN_init, options, r, K);
function f_prime = odefun(dataT, funcN, r, K)
f_prime = r * funcN * (1 - funcN / K);
end
Errors I'm getting:
??? Error using ==> logistic
Too many input arguments.
Error in ==> lsqcurvefit at 209
initVals.F =
feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Error in ==> logistic_growth_data_fit at 22
pFit = lsqcurvefit('logistic' , r0, dataT, dataN1) ;
Caused by:
Failure in initial user-supplied objective
function evaluation. LSQCURVEFIT cannot
continue.
0 Kommentare
Antworten (1)
Walter Roberson
am 14 Jul. 2011
Read the documentation . The function you supply (logistic) must take two parameters, but the function you defined takes no parameters. Even if you ignore the parameters for some reason, your function still has to expect them to be passed.
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!