plotfcns my own plot function with ADDITIONAL inputs

조회 수: 5 (최근 30일)
Masoud
Masoud 2013년 5월 8일
댓글: AdarG 2019년 3월 28일
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개)

Steven Lord
Steven Lord 2017년 11월 30일
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
AdarG
AdarG 2019년 3월 28일
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!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by