How to specify a parent UIplot for the plots that the bayesopt() funtion provides

1 次查看(过去 30 天)
I am using app designer. and I don't want the product plots when using the bayesopt() function with neural network training to just pop up in new figures but I'm have a hard time trying to find how I can specify a parent UI for them. my function looks like
BayesObject = bayesopt(opt.ObjFcn,opt.optimVars, ...
'MaxTime',opt.MaxOptimizationTime, ...
'IsObjectiveDeterministic',false, ...
'MaxObjectiveEvaluations',opt.MaxItrationNumber,...
'PlotFcn', {@plotObjective,@plotObjectiveEvaluationTime,@plotMinObjective,@plotElapsedTime},...
'Verbose',isLog,...
'UseParallel',false);

采纳的回答

Kevin Holly
Kevin Holly 2022-10-31
编辑:Kevin Holly 2022-10-31
I can think of a way of placing data into the app's UI once the bayeopt function has run. You could then immediately close of the pop up figure windows.
You could create panels and transfer axes to it (see app attached).
h = gca;
h.Parent = app.Panel;
close(gcf)
h = gca;
h.Parent = app.Panel_2;
close(gcf)
Or if you transfer the children of the pop up axes to the UIAxes in your app with something like this:
h = gca;
app.UIAxes2.XLabel = h.XLabel;
app.UIAxes2.YLabel = h.YLabel;
app.UIAxes2.Title = h.Title;
app.UIAxes2.XLim = h.XLim;
app.UIAxes2.YLim = h.YLim;
for ii = length(h.Children):-1:1
h.Children(ii).Parent = app.UIAxes2;
end
close(gcf)
h = gca;
app.UIAxes2.XLabel = h.XLabel;
app.UIAxes2.YLabel = h.YLabel;
app.UIAxes2.Title = h.Title;
app.UIAxes2.XLim = h.XLim;
app.UIAxes2.YLim = h.YLim;
for ii = length(h.Children):-1:1
h.Children(ii).Parent = app.UIAxes2;
end
view(app.UIAxes2,15,15)
close(gcf)
If you want each iteration to display like an animation on the uiaxes in the app, you could open the BayesianOptimization function and change the axes. Looks like the Axes is define between lines 616 and 635. Note, you may want to save a modified copy of the BayesianOptimization function and call it in a modified bayesopt function. Perhaps you could add an input to the function called app. Then have it plot on the uiaxes you desire (e.g. app.UIAxes).
open BayesianOptimization

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Model Building and Assessment 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by