How to convert an optimization variable to symbolic variable?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
B. Berk
am 9 Aug. 2022
Kommentiert: B. Berk
am 9 Aug. 2022
Hi everyone,
I need to convert an optimization variable that created by 'optimvar' command to a symbolic variable. I couldn't find any converter funtion for this one. I have a polynom consists of optimization variables, and i want to replace found values of some optimization variables in this polynom. If you know any other method for doing this, please let me know.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Aug. 2022
It does not appear to be documented, but use optimexpr2fcn() on the optimization expression, to get back a function handle to a .m that it will write in your current directory. The resulting function will expect only a single input that is a vector, all of the inputs concatenated together.
For example,
x = optimvar('x',3,2);
y = optimvar('y',1,2);
expr = sum(x,1) - 2*y;
syms X [3 2]
syms Y [1 2]
h = optimexpr2fcn(expr)
h([X(:); Y(:)])
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!