Adding weight to data points

3 visualizaciones (últimos 30 días)
LS
LS el 21 de Jul. de 2011
Hi all,
I'm working on basic model fitting in Matlab and now I'm trying to figure out how to add weight to certain data points and take away weight from others. I have the fitting down so that two of the parameters (r and K) are estimated successfully but the fit isn't great. I tried something (in the third cell of the first script copied below) that I had seen in previous code but it didn't work (no errors but estimated parameters that were way off). Any help would be much appreciated! Thank you!
%%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)
%%Giving data weight - what I've tried so far but it doesn't work
%points to take away weight
dataN1([14 16]) = 0;
%keep weight
dataN1([1 2 3 4 5 6 7 8 9 10 11 12 13 15 17 18]) = 1;
%%Curve fitting
% Initial estimates for r and K ( p0 = [r;K])
p0 = [0.1; 3.5e6] ;
% Estimate parameters
tic
pFit = lsqcurvefit(@logistic, p0, dataT, dataN1) ;
toc
~~~~logistic script (function used in previous script)
function funcN = logistic(p0, T_range)
%logistic growth equation for data fitting
%variables
funcN_init = 1e3;
%options
options = [];
% Solver
%to estimate r
[T funcN] = ode45(@odefun, T_range, funcN_init, options, p0(1), p0(2));
function f_prime = odefun(T, funcN, r, K)
f_prime = r * funcN * (1 - funcN / K);
end
end

Respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by