Same functionality as Excel Solver to set objective to a value
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all
I am currently going through a process of taking an existing calculation perfomed within Excel and transferring it to MATLAB. Part of the existing calculation is to use Excel Solver to optimise two factors to allow a value to be calculated which matches a target value. This was achieved in the Excel solver by setting the objective to a fixed value using the 'Value Of' input box.
Going through the MATLAB optimisation functions I can only find solutions to minimise the value. My question is what function would I use to target a value? Note that I do not have the optimisation toolbox installed.
Many Thanks
Peter
0 Commenti
Risposta accettata
Alan Weiss
il 7 Giu 2012
I am not sure I understand your question. If you have a single function of a single variable, you can use fzero to solve for f(x) = a, by solving for a zero of the function f(x) - a.
However, you seem to have a single function of two variables, or perhaps you have two functions of two variables. If you have two functions of two variables, use fsolve to find a solution. If you have a single function of two variables, I don't understand what you or Excel can do to find a solution, because in general there are multiple solutions.
And I do not recommend using abs in Optimization Toolbox functions, this introduces unnecessary nonsmoothness. Use a square if you need to (but you probably do not need to).
Alan Weiss
MATLAB mathematical toolbox documentation
Più risposte (1)
Titus Edelhofer
il 7 Giu 2012
Hi Peter,
to optimize a variable to be of value XTarget, you need to minimize the function
abs(x - XTarget)
If you don't have restrictions, you can use fminsearch as solver.
Titus
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!