Fitting data to a nonlinear model to estimate parameters

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?

답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

JVM
2018년 3월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by