Why does my GUI code sometimes not update when debugging / making changes on the fly?

7 visualizaciones (últimos 30 días)
I am writing another GUI for making my life easier when processing common datasets. This is without using guide or anything, just creating axes, tabs, buttons, etc using the uicontrol commands, then running various processing techniques within the GUI. My question (which has always bugged me), is why sometimes when I make a small change to code that the GUI uses, this change is not registered during debugging.
In fact, even if I close and reopen the GUI figure window, the code does not seem to update. It sometimes takes closing Matlab down completely, then reopening in order for the code change to "register". As an example, let's say I am plotting something and want to make a small change that plots an additional point or line or something. I press the button or interact with the GUI in whatever way re-runs that code, but nothing happens. If I run it in debug mode, sometimes it will skip the line entirely, but other times it will seem to step through the new code, just using wrong values (from a previous iteration or whatever). In these cases, it takes a whole shutting down and reopening of Matlab to get the code to behave the way I expect!
Is there some kind of underlying "compiling" that goes on during GUI generation that causes this issue? I have never seen behavior like this when simply running scripts, etc., only when working with GUIs. If there is some kind of compiling that goes on, is it possible to disable this or force it to "recompile" just by restarting the GUI (rather than all of Matlab)? Am I the only one experiencing issues like this? It's annoying when you are debugging and working out details of a GUI on a daily basis.
  1 comentario
Jeff Grothaus
Jeff Grothaus el 18 de Abr. de 2024
I am having this same problem when making GUI code changes (using App Builder) in 2024. I am using R2023a on Win10. As an example, changing "if ..." to "if ~..." does not change the behavior when the function is executed, say from a button on the GUI.
The link in Walter's solution to the jit accelerator no longer points to a valid page. Additionally, neither clearing the function nor setting "feature accel off" seem to affect this behavior. All hits for searches along the lines of "just in time accelerator" in the MatLab docs point to Simulink pages.
I had thought that the code generated by App Builder had been corrupted by switching from R2022a to R2023a and back, however, I just rebuilt the GUI only using R2023a and the problem persists.
Any thoughts would be appreciated.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 31 de Mayo de 2016
Use "clear" and the name of the function.
Yes, there is Just In Time Compiling. The function will normally be cleared automatically if MATLAB detects that the containing file is changed, but there are various ways that might not be detected.
  1 comentario
Ryan
Ryan el 31 de Mayo de 2016
Editada: Ryan el 31 de Mayo de 2016
Thanks for pointing me there. Your answer brought me here: jit (Just in Time) Accelerator
And this post points to how to turn it off globally:
feature accel off
I think when I'm constantly debugging and adding features, etc., I'll just turn this off, and once the GUI is mostly dialed in, I'll turn it back on.
Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by