fetch variables from a script and use its value in a matlab app

조회 수: 5 (최근 30일)
Muhialdeen Ibrahim
Muhialdeen Ibrahim 2019년 11월 27일
답변: Vimal Rathod 2019년 12월 5일
Hi,
Im trying to use different variables from my script in different GUI elements in my app.
I have no idea how to do that and would be thankful if someone can help
for example I want the scoreM Variable to be displayed in an EditText field und the seperate values from the indexes of the vector would like them to be displayed seperately in other seperate EditText fields. I also would like to change the boolean variable wurfelAkzeptiert when I click a button from false to true.
Ive read that I shoud use functions to pass those variables to the GUI but I honestly have no idea how to do that. Ive been working with Matlab only for the past 2 months and now I have to programm a dice game and im finished but cant connect the logic from my code to the GUI.
Any kind of advice, short, long or excessively detailed will be much appreciated.
for j=1:3
wuVekM(j) = randi(6);
mWAuge1 = wuVekM(1);
mWAuge2 = wuVekM(2);
mWAuge3 = wuVekM(3);
sort(wuVekM);
end
if(wurfelAkzeptiert && (mDran) || wurf == 3) %durch einen Button kontrolieren
scoreM = sum(wuVekM);
  댓글 수: 1
Jan
Jan 2019년 11월 28일
I do not understand, what you want to achieve. The question is rather general.
The purpose of the posted code is not clear. The line sort(wuVekM); does nothing, because the sorted values are not assigned to an output. The loop fails, because wuVekM(2) is not defined which j==1:
for j=1:3
wuVekM(j) = randi(6);
mWAuge1 = wuVekM(1);
mWAuge2 = wuVekM(2);
mWAuge3 = wuVekM(3);
end

댓글을 달려면 로그인하십시오.

답변 (1개)

Vimal Rathod
Vimal Rathod 2019년 12월 5일
If the script is run in the app, the variables of the script can be used in the app. The best way would be to call the script in the ‘StartupFcn’ of the app

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by