automatic read the file and stop the reading

3 Ansichten (letzte 30 Tage)
renoald Tang
renoald Tang am 19 Mär. 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 ?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Mär. 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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by