フィルターのクリア

Creating function variables to be filled with EditField Inputs

5 ビュー (過去 30 日間)
Brett
Brett 2023 年 10 月 13 日
コメント済み: Florian Bidaud 2023 年 10 月 16 日
I have an existing script that runs based on set numbers. I am trying to create a GUI that will allow the user to replace those numbers from the interface rather than editing the actual script. I was trying to assign the values from the EditField numeric to variables which could then be placed into the script (rewrittten as a function for external calling for the same path).
I tried assinging that neccessary variables for the function myfunc(q,w,e,r,t,y,u,i,o). I tried assigning the variables like below to the existing internal names (dt = q rather than dt = 2000 like the original script).
dt = q;
tmin = w;
istart = e;
iend = r;
th_high = t;
th_medium = y;
th_low = u;
spot_rad=i;
rem_size=o
I am a novice to matlab and app designer as a whole. Thank you in advance.

採用された回答

Florian Bidaud
Florian Bidaud 2023 年 10 月 13 日
編集済み: Florian Bidaud 2023 年 10 月 13 日
Hi
My guess is you don't need the app designer for such a simple thing. you could simply use the function input.
So basically:
dt = input('dt = ');
tmin = input('tmin = ');
istart = input('istart = ');
iend = input('iend = ');
th_high = input('th_high = ');
th_medium = input('th_medium = ');
th_low = input('th_low = ');
spot_rad = input('spot_rad = ');
rem_size = input('rem_size = ');
If you really want to use app designer:
You need to create edit fields and a button like this for example :
Then create a Callback on the button like follows:
Then you can assign your variables from the edit fields in the push button callback function:
% Button pushed function: RunCodeButton
function RunCodeButtonPushed(app, event)
dt = str2double(app.dtEditField.Value);
tmin = str2double(app.tminEditField.Value);
istart = str2double(app.istartEditField.Value);
% Write the rest of you script here
end
If you then want to use these variables in a completly external script, my advise would be to save them in a .mat file with save, and load them back in the external script.
  2 件のコメント
Brett
Brett 2023 年 10 月 13 日
So if I were to paste the rest of my script where you noted, would I need to define or adjust the variables elsewhere or could they just be taken as it?
Florian Bidaud
Florian Bidaud 2023 年 10 月 16 日
They could be taken as it.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by