plotfcns my own plot function with ADDITIONAL inputs

7 vues (au cours des 30 derniers jours)
Masoud
Masoud le 8 Mai 2013
Commenté : AdarG le 28 Mar 2019
Hello,
I'd like to call my own plot function at each iteration of "fminsearch" or "ga" but to plot my own diagram I need some additional inputs.
How can I have additional input in my own plot function?
Currently, my function is in the form of
function stop = MyPlot(x,state,flag)
I need something like
function stop = MyPlot(x,state,flag, input1, input2)
where input1 and input2 are constants.
Thanks in advance.
  1 commentaire
Eric H.
Eric H. le 29 Nov 2017
Has anyone found a way to do this?

Connectez-vous pour commenter.

Réponses (1)

Steven Lord
Steven Lord le 30 Nov 2017
The "Plot Options" section on this documentation page references a documentation page titled "Passing Additional Parameters" in Optimization Toolbox. You can use the same techniques for passing additional parameters into a plot function as you can into an objective or constraint function. For example, if extra1 and extra2 are defined when you execute this line of code and myRealPlotFun accepts five or more inputs:
myplotfun = @(options,state,flag) myRealPlotFun(options, state, flag, extra1, extra2);
you can specify myplotfun as the plot function.
  1 commentaire
AdarG
AdarG le 28 Mar 2019
Hi Steven,
I didn't fully understand your answer. I want to plot the vectors v1 and v2 that are calculated during the ga optimization. Where should I define myplotfun as:
myplotfun = @(options,state,flag) myRealPlotFun(options, state, flag, v1, v2);
Specifically, How should I state the options struction?
options = optimoptions('ga','PlotFcns', {@gaplotbestf, @myplotfun})
How do I define the function myplotfun to plot v1 and v2?
function myplotfuc(options,state,flag,?)
Thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Optimization 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!

Translated by