Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Why a variable randomly is not updated in MATLAB GUI using guidata function?

1 vue (au cours des 30 derniers jours)
RZM
RZM le 7 Sep 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hello, I have a problem in a GUI made using MATLAB Guide.
I have some timer functions which are executed sequentially. There is one variable (handles.UserData.C_cnt) which is shared between the timer functions. The variable is not updated after some random number of the execution of the timer function and I cannot figure out why this occurs. Could you check if the following structure I use for updating the variables inside a timer function is correct?
function timer_fcn(obj,event,hObject,eventdata)
handles = guidata(hObject);
handles.UserData.C_cnt = handles.UserData.C_cnt+1;
guidata(hObject, handles);
  3 commentaires
RZM
RZM le 7 Sep 2018
Modifié(e) : RZM le 7 Sep 2018
I agree. Some experts recommend not to use global variables and they are evil so I tried to avoid them in GUI. But here when I use global variables it works fine so in this case I call them angels. :D I have also used eval function which is not recommended, maybe this random problem came from that but I had no other choice.
Stephen23
Stephen23 le 7 Sep 2018
@RZM: please upload your code by clicking the paperclip button.

Réponses (0)

Cette question est clôturée.

Tags

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by