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 Commento

@KSSV sorry I'm new to asking question, I just deleted the previous problem. Please refer to this new one.

Accedi per commentare.

 Risposta accettata

Walter Roberson
Walter Roberson il 5 Feb 2021

0 voti

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 Commento

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!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Prodotti

Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by