How to use fmincon and/or similar optimilisation constraints

4 views (last 30 days)
I want to know how to use the fmincon function. My current code is this:
function superhydrogenusage
Q = 0:1:40000000;
P = 400/(9*(((10*Q - 8000/27)^2 - 64000000/729)^(1/2) - 10*Q + 8000/27)^(1/3)) + (((10*Q - 8000/27)^2 - 64000000/729)^(1/2) - 10*Q + 8000/27)^(1/3) + 20/3;
F = 100
v = P/F;
fmincon
end
What needs to be done here is that Q is a function of the velocity v. The velocity v has a constraint. A car needs to pass a finish line that's 32000 m away. And it needs to be there before the time is up. The time is two hours (7200 seconds). I want the fuel usage Q to be minimised by fmincon. How can I use the function to adapt the given constraints?

Answers (1)

Alan Weiss
Alan Weiss on 21 Jan 2014
fmincon requires that you put your problem into the syntax that it expects. It expects that you have some parameters, say a vector x, that it can vary. You have to write an "objective function" that gives the cost f(x) for each value of the parameter x. Then fmincon will try to find x to minimize f(x).
For more information, I suggest that you look at an introductory example, and look at the documentation on Optimization Problem Setup.
Alan Weiss
MATLAB mathematical toolbox documentation

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!