Creating function variables to be filled with EditField Inputs
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!