Bayesian Optimization Output Functions within Matlab App

조회 수: 5 (최근 30일)
Jon
Jon 2021년 8월 5일
댓글: Ulrich Streppel 2023년 1월 20일
Hi,
I'm trying to implement an optimization process, based on the bayesopt method, integrated into a GUI, made with application designer. Everything works fine except for the output function, which I'm having trouble with the arguments.
In the help section, the description is relatively straight forqward as
results = bayesopt(fun,vars,'OutputFcn',@outputfun,...
implying the automatic arguments results and state.
However, when calling a function within an app, I need to also supply the argument app. I tried several ways, including an anonymous function like
outFunc = @(x)outputFunction(app,x.results,x.state);
but just can't make it work. Depending on the formatting and whether or not uing the anonymous function, I always get one of the following two errors:
  • Dot indexing is not supported for variables of this type.
  • Too many input arguments.
Maybe (and even hopefully) it's an obvious mistake with an easy fix. Does anyone know a solution to this?
Thank you!
  댓글 수: 1
Ulrich Streppel
Ulrich Streppel 2023년 1월 20일
is there any solution in the meanwhile? I have the same problem. How can the app argument integrated into an output function in app designer?

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

답변 (1개)

Alan Weiss
Alan Weiss 2021년 8월 8일
I don't know what you mean "when calling a function within an app, I need to also supply the argument app."
However, maybe I can help. As explained in Bayesian Optimization Output Functions, an output function takes the signature
stop = outputfun(results,state)
So you might need the signature
@(results,state)outputfun(results,state)
But as far as I know that is the same as
@outputfun
so I am not sure that my advice is going to change anything for you.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
Jon
Jon 2021년 8월 9일
Thanks for your reply and sorry, if I didn't describe it clearly enough.
The function should be called, including a third (or rather first) argument "app", handing over the app handle/object, as in
outFunc = @(results,state)outputFunction(app, results, state);
because the function itself also should be initialized like the following
function outVal = outputFunction(app, results, state)
This is of course only true, if inside an app designer environment. Otherwise, to my understanding there is no way of accessing the private data, callbacks and functions of the GUI and app itself. Now how can I use the bayesian output function implementation without errors regarding input arguments?
Outside of an app, with just the result and parameters given, it's a simple imlementation and working perfectly fine for me.

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

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by