Simulation: fminsearch in a for loop
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nicolas Macallister
le 17 Août 2021
Réponse apportée : Alan Weiss
le 17 Août 2021
options=optimset('TolFun',1000,'TolX',0.25,'Display','iter','PlotFcns',@optimplotfval);
output=[];fval=[];
for i=1:5
[output(i),fval(i),exitflag,output]=fminsearch(@myfunc,300,i,options);
end
I would like to find an independant set of minima using fminsearch without manually updating @myfunc each time, rather just sending i along with initial guess x0 (300) to the function which corrosponds to an index within the function definition (something like the above code.) Is this possible?
0 commentaires
Réponse acceptée
Alan Weiss
le 17 Août 2021
Do you really want TolFun = 1000? Are you sure?
I am not sure that I understand what you are trying to do, but maybe you have an extra parameter (i in your pseudocode) that you want to pass. If so, then I suggest that you create i as a parameter that you pass using a nested function call, as described here or here.
Alan Weiss
MATLAB mathematical toolbox documentation
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!