nonlinear least square optimization
3 views (last 30 days)
Show older comments
Where,
and known
I want to solve this problem by using a nonlinear least square optimization . This is the code I tried to use but I am receiving an error
fun = @(x) sum( ( A.'*x + B.'*x - (C.'*x) -b ).^2 ); % A is X_k coeffecients , B is Y_k coefficents , C is Y_k squared coefficents , b is b_k ^2
Aeq = ones(1,5);
lb = zeros(1,5);
x0 = ones(1,5)/5;
x = lsqnonlin(fun,x0,lb)
Any adivce to improve my code are appreciated.
0 Comments
Answers (1)
Star Strider
on 10 Jan 2023
The Symbolic Math Toolbox is not appropriate for this. Use the Optimization Toolbox function lsqcurvefit instead (since you apprarently want to bound the parameters). If you have defined the function symbolically, use the matlabFunction function to convert it to an anonymous function you can use with lsqcurvefit. See especially the documentation section on Vars since that will allow you to define the order of the arguments and the parameter vector so that it will work correctly with the optimisation functions.
0 Comments
See Also
Categories
Find more on Nonlinear Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!