How do I do a multivariate nonlinear least squares problem using the LSQNONLIN function in the Optimization Toolbox 3.1.2 (R2007b)?
3 ビュー (過去 30 日間)
古いコメントを表示
I wish to solve a multivariate nonlinear least squares problem using the LSQNONLIN function. I tried the example from the documentation for this but the the following commands appear to work only for 1 independent variable :
function F = myfun(x)
k = 1:10;
F = 2 + 2*k-exp(k*x(1))-exp(k*x(2));
採用された回答
MathWorks Support Team
2010 年 2 月 5 日
In order to solve a multivariate non-linear least squares problem, you need to define input 'x' as a matrix, where each row corresponds to an
independent variable. However, since you can only pass a vector, you would
need to first reshape the matrix into a vector and reshape it back into a matrix
in the function.
Hence a modification of the code will be as follows:
function F = myfun(x)
% reshape x back to a matirx
k = 1:10;
F = 2 + 2*k-exp(k*x(1))-exp(k*x(2));
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!