Change variables in an infinite loop

Hello everyone,
I'm creating an app with matlab appdesigner, to dynamicly adjust some parameters in a running function. I want to design a slidebar such that I could adjust variables while the function is running, so that I could monitor the performance of the function in real time. Is there any way to achieve that?
Look forward to your help.

1 comentario

Jin Ren
Jin Ren el 5 de Feb. de 2021
@KSSV sorry I'm new to asking question, I just deleted the previous problem. Please refer to this new one.

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 5 de Feb. de 2021

0 votos

If the function does not call pause or drawnow or uiwait or figure, then you need to go into the editor and trick it to open the file (which is sometimes only possible if it happens to be in the recent list or you happen to have the folder view open.) Once it is open, right click at the appropriate place to insert a breakpoint at a line and wait for execution to stop; then you can use the command line to change the value and then dbcont to continue.
In some cases you might need to resort to injecting a dbstopfor a lline tthat has a condition aattached to it, except that you make the condition be a call to a function that alters the variable as a side effect using assignin caller, and then returns false so that the debugger thinks the condition was not matched and continues execution.
Mostly though you should not do this, and should instead arrange to share a variable and have some gui that changes the variable value, with the loop checking for changes periodically.

1 comentario

Jin Ren
Jin Ren el 5 de Feb. de 2021
Actually what I want to do is exactly your last paragraph, and I just find that matlab works well with this. Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Preguntada:

el 5 de Feb. de 2021

Comentada:

el 5 de Feb. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by