Problem using lsqnonlin with nlparci toolbox

I have a problem when calculating the confidence intervals using lsqnonlin and nlparci toolbox.
I wanted to calculate the CI using the Jacobian, however, I am getting the following error: Error using nlparci (line 93) The size of J does not match the sizes of BETA and RESID. I am fitting 6 parameters.
Here is the syntax of the fitting function and of the calculation of the CI.
[par_out, residual,jacobian] = lsqnonlin(@eq_2D3D1TR_set, MAT1,zeros(1,i),MAT2, options, tau_range, g_in_range,MAT3,FIX);
ci = nlparci(par_out, residual, 'jacobian', jacobian);
@eq_2D3D1TR_set is the fitting method
MAT1 are the starting points
zeros(1,i) and MAT2 are the lower and upper bounds
options contain different options of the fitting: options=optimset('Display', 'final','LargeScale', 'Off', 'DiffMaxChange', 0.1, 'DiffMinChange', 0.00001,'TolFun', 1e-100, 'TolX', 0.001, 'MaxFunEvals', 5000, 'MaxIter', 1000);
tau_range, g_in_range are the input data with the selected range
FIX contains information about which of the parameters are fixed during the fitting (the GUI provides this information)
Currently I am fitting with all of the 6 parameters non-fixed.
Truly, when I have a look at the computed Jacobian and residual, then the Jacobian has only 1 column (instead of 6 since I have 6 parameters) and the residual contains only 1 number, what seems also not OK.

 채택된 답변

Alan Weiss
Alan Weiss 2017년 7월 19일

0 개 추천

You can give the outputs of lsqnonlin any names you like, but calling the third output "jacobian" doesn't mean that it returns the Jacobian of your function:
[par_out, residual,jacobian] = lsqnonlin(@...
The lsqnonlin function reference page shows that the function has this signature:
[x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(___)
In other words, the Jacobian is the seventh output, not the third.
Alan Weiss
MATLAB mathematical toolbox documentation

댓글 수: 1

Ed
Ed 2017년 7월 20일
Thank you Allen very much, you just made my day!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

질문:

Ed
2017년 7월 19일

댓글:

Ed
2017년 7월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by