How to use the handle of APP Designer in MATLAB Function?

17 次查看(过去 30 天)
Hi!
I have a GUI designed in the APP Designer named App1, in the Model callbacks I set InitFcn as
happ = App1;
I want to change something in the App1 such as
happ.EditField.Value = u;
u is the input of the Matlab Fuction in my Simulink model. The changing is failed, happ can not use in the MATLAB Fuction. I am trying to set happ as parameter. It not work.
Who can slove the question? I really appreciate it.

回答(1 个)

Adam Danz
Adam Danz 2020-6-9
'u' should be a character vector or string scalar.
If you're trying to input a numeric value, it must first be converted to a string using num2str() or sprintf() or compose() (and others).
If the error persists, please share the entire error message, the value of u, and please confirm that EditField is a text edit field.
  3 个评论
Adam Danz
Adam Danz 2020-6-10
There are two ways to access the app handle from within any function.
1) Pass the handles as a variable.
myFunction(input1, input2, app)
2) "Find" the app handle from within the function. See this demo for an example, see section "Find the handle to an app that's already opened".

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by