Azzera filtri
Azzera filtri

How can i optimize a symbolic function?

5 visualizzazioni (ultimi 30 giorni)
Natanael Acencio Rijo
Natanael Acencio Rijo il 6 Dic 2013
Risposto: Andrei Bobrov il 6 Dic 2013
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.

Risposte (1)

Andrei Bobrov
Andrei Bobrov il 6 Dic 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)});

Categorie

Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by