Link MATLAB script with App Designer

227 ビュー (過去 30 日間)
Hidd_1
Hidd_1 2022 年 1 月 6 日
回答済み: Walter Roberson 2022 年 1 月 6 日
Hey Everybody!
I wrote a Matlab script of a program which automate Data processing, and then I thought about creating an GUI for it using App Designer, but unfortunately I am having trouble translating the code from the Matlab script to the App Designer. (The syntax of the App designer is kind of new for me)
Thus I would prefer to link the App Designer direclty with the Matlab script without the need to rewrite the code.
Can anyone share a tip? or an example?
Thank you in advance!

採用された回答

Walter Roberson
Walter Roberson 2022 年 1 月 6 日
At any point in an App Designer callback, you can just name the script to run the script.
function edit1_callback(whatever)
myscript;
end
See also http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F -- because the workspace when you call the script will be the workspace of the function.
Also, if you need any values set by the script inside the function, you should initialize the variables before you call the script.
function edit1_callback(whatever)
tf = []; %any value, just have to initialize it
myscript;
app.EditField3.Value = tf;
end
if you do not initialize the variables before you call the script, then MATLAB is permitted to assume that the variable tf refers to the tf function. ( tf is being used as an example here: the point is that you should initialize the names or else MATLAB is going to think that they refer to functions.)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by