When optimizing parameters, how to increase or decrease the parameters participating in optimization without modifying the code
Afficher commentaires plus anciens
L is parametaer needing to be optimized. We do not care about other parameters. The actual fun is complex,but I simplified it to following fun.
fun=@(x1,x2,t,L) x1 .* x2 .* (L(1)+L(2)*t);
[L,resnorm] = lsqnonlin(@(L)fun(x1,x2,t,L)-y, [0 0])
If the optimization result is not good, I need to add an L(3),L(4):
fun = x1 .* x2 .* (L(1)+L(2)*t+L(3)*t^2)
fun = x1 .* x2 .* (L(1)+L(2)*t+L(3)*t^2+L(4)*t^3)
And so on.
So I want to know how I can write code so that I can modify the optimized parameters without modifying the code of this fun. I know that many items of L may need to be written in advance in code, and then the optimized parameters can be selected. How to achieve it, I hope you can give me a solution or idea, I will be very grateful to everyone.
Réponses (0)
Catégories
En savoir plus sur Get Started with Optimization Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!