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

5 visualizaciones (últimos 30 días)
Muhialdeen Ibrahim
Muhialdeen Ibrahim el 27 de Nov. de 2019
Respondida: Vimal Rathod el 5 de Dic. de 2019
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 comentario
Jan
Jan el 28 de Nov. de 2019
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

Iniciar sesión para comentar.

Respuestas (1)

Vimal Rathod
Vimal Rathod el 5 de Dic. de 2019
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

Categorías

Más información sobre Debugging and Analysis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by