How can i optimize a symbolic function?

5 次查看(过去 30 天)
I got a function which gives this final result:
5.3*p(1) + 5.5*p(2) + 5.8*p(3) + 0.004*p(1)^2 + 0.006*p(2)^2 + 0.009*p(3)^2 + 1100.0
I want to find the minimum of this function using GA in the optimization toolbox. The problem here is that the function is in sym class, and when i try to convert to double the variables are not converted.
Note: i must not assign values to p before optimizing,this is to be done by the optimization algorithm.

回答(1 个)

Andrei Bobrov
Andrei Bobrov 2013-12-6
Please try this is code:
z = ...
subs(5.3*p(1) + 5.5*p(2) + 5.8*p(3) +...
0.004*p(1)^2 + 0.006*p(2)^2 + 0.009*p(3)^2 + 1100.0,p,sym('p_',[numel(p),1]));
fun = matlabFunction(z,'vars',{symvar(z)});

类别

Help CenterFile Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by