Fitting data to a nonlinear model to estimate parameters

2 visualizzazioni (ultimi 30 giorni)
I am trying estimate two unknown parameters in a nonlinear model. The script that is have made works for some iterations but suddenly stops. The code is as follows:
ws; % some data with 8 columns and n rows
a = 0.0144; % constant
g = 9.81; % constant
k = 0.4; % constant
h = [30,40,50,60,70,80,90,100,106];
x0 = [100,-1];
options = optimoptions(@lsqnonlin,'Algorithm','trust-region-reflective');
for i = 1:size(ws,1)
v = ws(:,i);
fun = @(x) x(1)/k*(log(h/(a*x(1)^2/g))-x(2))-v;
x = lsqnonlin(fun,x0,[],[],options);
ustar(i) = x(1);
Psi_M(i) = x(2);
end
Is there a more effecient way of fitting the data to the model which also outputs the two unknown parameters?

Risposte (0)

Categorie

Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by