Using fminunc with blackbox
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
jeff
am 23 Mär. 2016
Beantwortet: sanya gode
am 29 Okt. 2019
A blackbox code (obj_b3.p) defines a function that takes a vector of length 2 and returns some value based on that function. I want to find the global minimizer, and instead of guess and check I want to use fminunc (have never used before, have looked at doc and help and tried googling examples but they all have known functions that they make anonymous). To do this I intend on using a lot of x0 (guess) values.
how do i set up the basic code?
what I've tried:
v = [1;1] % creates a vector of length 2 (blackbox code won't accept a 1,2, only a 2,1)
x0=[0;0]; % Initial guess for fminunc
v = fminunc(obj_b3,x0)
matlab returns that there aren't enough inputs.
Can someone post a simple example of how to do this using a blackbox.m file (hope its obvious that the blackbox.p file does not allow one to actually see the code to evaluate).
Thanks!
0 Kommentare
Akzeptierte Antwort
Alan Weiss
am 23 Mär. 2016
fun = @obj_b3;
x0 = [0;0];
x = fminunc(fun,x0)
You might want to consult the documentation on optimizing a simulation or ODE in case your black-box function does not distinguish between nearby values very well.
Alan Weiss
MATLAB mathematical toolbox documentation
2 Kommentare
Alan Weiss
am 23 Mär. 2016
The point is, how can you tell MATLAB to work with a function? I mean, you want to take a function ( fminsearch ) that operates on another function (your objective). So how should you pass the objective? The answer is with a handle to the objective.
Alan Weiss
MATLAB mathematical toolbox documentation
Weitere Antworten (1)
sanya gode
am 29 Okt. 2019
Hello,
I am working on Equivalent Circuit Modeling for estimating the battery parametrs. I read in MAthworks documentation that the model can be Blackboxed for sharing with certain customers so that they can modeify it accourding o the application for which they are using the battery without knowing the internal parameters. I read that once the model is created we need to generate the code and than we have create a new simulink model based on the generated code.
Can you please elaborate on how exactly do we need to blackbox the model based on the generated code ?
Your answers will be very helpful and appreciated.
Thanks in advance.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!