How to use ga() without generating a prepopulated figure with stop and pause button with matlab app
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dominik Mair
am 3 Dez. 2020
Kommentiert: Dominik Mair
am 11 Dez. 2020
I am trying to build a matlab app which uses the ga function for genetic optimization. It is possible to define an own plotfcn (in this case plotnd) which is called every time a generation is built.
options = optimoptions('ga');
% Some Code
options = optimoptions(options,'PlotFcn', @plotnd);
% Some Code
[x,fval,exitflag,output,population,score]=ga(..... ,options);
I use this function to plot the best individual inside of my matlab app UIAxes object:
function state = plotnd(options, state, flag)
% Some Code (generate Data to plot out of state)
% Find Running Matlab App
app = get(findall(0, 'Name', 'MyMatlabApp'), 'RunningAppInstance');
% Get UIAxes of Matlab App
ax = app.OptimizationPlot;
% Plot Data From state Within UIAxes
plot(Data.X,Data.Y,'Parent', ax)
% Some Code
end
The function plotnd is called and the Data (Data.X and Data.Y) is plotted correct in my matlab app.
However, everytime the plotnd function is called, matlab opens a UI Figure populated with a stop and a pause button.
Is there any way, that matlab is not opening this figure? I want to create my own stop and pause buttons within my matlab app.
Thank you in advance!
0 Kommentare
Akzeptierte Antwort
Alan Weiss
am 4 Dez. 2020
If you don't want the buttons, then use an output function instead of a plot function. See Custom Output Function for Genetic Algorithm.
Alan Weiss
MATLAB mathematical toolbox documentation
Weitere Antworten (1)
Benjamin Kraus
am 3 Dez. 2020
This looks like a limitation of the ga code that creates the buttons, as I can't see any way to control where those buttons are placed or whether they are created at all. I suggest contact MathWorks Technical Support to request this as an enhancement.
2 Kommentare
Benjamin Kraus
am 4 Dez. 2020
Bearbeitet: Benjamin Kraus
am 4 Dez. 2020
Correction: See Alan Weiss's reply about using an output function instead of a plot function.
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!