Optimizing/Minimizing multivariant equation with fminunc function
Mostra commenti meno recenti
I want to minimize a multivariate function which is dependent on 5 variables. (a,b,c,d,e) or (x(1),x(2),x(3),x(4),x(5)). I want to optimize/minimize this function to give me values of all 5 variables.
I need help in using this function. I am looking for exact code to optimization with fminunc that would work for me.
Below both equations are same first one has variables a,b,c,d,e and second has variables x(1),x(2),x(3),x(4),x(5).
Thanks
EQUATION with (a,b,c,d,e) variables
f = @(a,b,c,d,e) (-24951.7481672607*c*e)-(31692.9973208411*b*e)+(3225.11425786636*b*d)-(16419.7612619098*a*e)+(6432.88280411328*a*d)+(21319.7492059262*a*c)-(774.242787454529*d*e)-(969.74514540837*c*d)+(114650.02403548*b*c)+(9559.61986707961*a*b)-(10063.1833861524*(e^2))+(45673.2789241553*(d^2))+(54066.6037689217*(c^2))+(43331.1131990043*(b^2))+(33417.5807194389*(a^2))+ 84490.9661074925*e)-(83022.7768867125*d)-(158265.888247206*c)-(133009.535038023*b)-(76817.465849786*a)+120593.991848581
OR
EQUATION with (x(1),x(2),x(3),x(4),x(5)) variables
f = (-24951.7481672607*(x(3))*(x(5)))-(31692.9973208411*x(2)*x(5))+(3225.11425786636*x(2)*x(4))-(16419.7612619098*x(1)*x(5))+(6432.88280411328*x(1)*x(4))+(21319.7492059262*x(1)*x(3))-(774.242787454529*x(4)*x(5))-(969.74514540837*x(3)*x(4))+(114650.02403548*x(2)*x(3))+(9559.61986707961*x(1)*x(2))-(10063.1833861524*(x(5)^2))+(45673.2789241553*(x(4)^2))+(54066.6037689217*(x(3)^2))+(43331.1131990043*(x(2)^2))+(33417.5807194389*(x(1)^2))+(84490.9661074925*x(5))-(83022.7768867125*x(4))-(158265.888247206*x(3))-(133009.535038023*x(2))-(76817.465849786*x(1))+120593.991848581
Risposte (1)
Alan Weiss
il 22 Ago 2012
In your case, your objective functon f should accept a vector x and return f(x), such as
f = @(x) (-24951.7481672607*(x(3))*(x(5)))-....
Alan Weiss
MATLAB mathematical toolbox documentation
2 Commenti
Walter Roberson
il 22 Ago 2012
You would get that problem if your x0 was a scalar.
Categorie
Scopri di più su Solver Outputs and Iterative Display in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!