Clear Filters
Clear Filters

How can i optimize a symbolic function?

5 views (last 30 days)
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.

Answers (1)

Andrei Bobrov
Andrei Bobrov on 6 Dec 2013
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)});

Categories

Find more on Get Started with Optimization Toolbox 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!