Creating function variables to be filled with EditField Inputs
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Brett
am 13 Okt. 2023
Kommentiert: Florian Bidaud
am 16 Okt. 2023
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.
0 Kommentare
Akzeptierte Antwort
Florian Bidaud
am 13 Okt. 2023
Bearbeitet: Florian Bidaud
am 13 Okt. 2023
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!