Variables cannot be recognized in app designer

3 ビュー (過去 30 日間)
Xiangfeng
Xiangfeng 2024 年 6 月 6 日
回答済み: Kumar 2024 年 6 月 6 日
I wrote a program in a script and it works, but it doesn't work in app designer. The unrecognizable code is shown below (a part of the calling function). Thank you very much for your time.

回答 (2 件)

Matlab Pro
Matlab Pro 2024 年 6 月 6 日
I've just tried it, It works 100% OK
Look @ the screenshot (attached)
What you must make sure is that you do have a "p_train" variable exiting in the "base" workspace
p_train = 'here is an answer for your question';
Anyhow (for future issues) - when you have an error - and you need some help - send the exact Error message
  1 件のコメント
Xiangfeng
Xiangfeng 2024 年 6 月 6 日
p_train and t_train are located in the objective function script. When I run the app to call the objective function, an error occurs (as shown in the figure below).

サインインしてコメントする。


Kumar
Kumar 2024 年 6 月 6 日
Hey!
To achieve this, you could turn the script into a MATLAB function that returns the variables as a function output. Then, you can call the function with the variables you need from, within app designer, and it will return the value to a variable you specify.
You can refer to this tutorial to get a basic understanding on how to convert a script into a MATLAB Function: https://www.mathworks.com/help/matlab/creating_guis/create-a-simple-app-or-gui-using-app-designer.html

カテゴリ

Help Center および File ExchangeDevelop 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