Effacer les filtres
Effacer les filtres

automatic read the file and stop the reading

1 vue (au cours des 30 derniers jours)
renoald Tang
renoald Tang le 19 Mar 2012
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 ?

Réponse acceptée

Walter Roberson
Walter Roberson le 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

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by