automatic read the file and stop the reading

3 visualizzazioni (ultimi 30 giorni)
hai , my gui have two button - start and pause. when the button start is press , the gui will automatically read all the file with specific extension (let say off) until i press the pause button.
The challenge is :
(1.) How i infinite loop for reading the file ?
r=-1;
while r < 0
//mycode here
end while .
how can i termiate the loop by using pause button ?
let say press pause button , r become > 0
(2.) when in the while loop , i press the pause button , not any effect on the gui!As i know , the pause button only work when the while loop is stop!This mean i can not press the button until the loop is stop , i can not do two thing in same time (Multithreading in programing)! any solution about this ?

Risposta accettata

Walter Roberson
Walter Roberson il 19 Mar 2012
The solution to #2 is to add a drawnow() statement in your loop. That tells MATLAB that it is okay to process any pending interruptions such as from a button push.
There are numerous ways to communicate the change in r; see for example http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by