fminsearch for existing simulation

1 view (last 30 days)
Chris Topher
Chris Topher on 14 Sep 2020
Commented: Walter Roberson on 14 Sep 2020
Hey guys,
I have recently created an aerodynamic trajectory model. The goal is to optimize for two Values for which i have an equation that should be mnimal. Now i want to use fminsearch (or something else if it fits better) to run over my whole simulation and calculate the value of the equation. To optimize it, there are plenty of other input values in the equation, that should be considered and changed by fminsearch. How can i do that without putting my whole simluation in one formula?
I dont use additional toolboxes, nor Simulink.
Thanks!
  1 Comment
Walter Roberson
Walter Roberson on 14 Sep 2020
You can pass the handle of a true function to fminsearch . You are not required to pass the handle to an anonymous function.

Sign in to comment.

Answers (1)

Matt J
Matt J on 14 Sep 2020
As Walter said, fminsearch does not know or care how many lines of code are used to implement your objective function. Bear in mind, though, that fminsearch is not built for problems with many variables. With more than about 6 unknowns, it typically performs poorly.
  3 Comments
Matt J
Matt J on 14 Sep 2020
Edited: Matt J on 14 Sep 2020
I also got a tip with fminsearchbnd which is perfect because you can easily define boundaries
Since you appear to have only a single unknown variable, the stock Matlab function fminbnd would work as well.
The only thing i dont like is that i have to change the original simulation by passing the Init-values so it doesnt work without being called by optimizer anymore.
No, that's quite unnecessary. Your objective function can call other functions, so there is no reason why the simulation code cannot reside in its own mfile. The only thing fminsearch/fminbnd/fminsearchbnd cares about is that it has access to some function which takes a guess for the unknown as input and spits an objective function value back as output. It doesn't know or care what code is used to obtain that output value, or how that code is structured.
Walter Roberson
Walter Roberson on 14 Sep 2020
"To optimize it, there are plenty of other input values in the equation, that should be considered and changed by fminsearch"
To me that suggests that the number of variables to be optimized over is more than 1.

Sign in to comment.

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!