automatic read the file and stop the reading

4 次查看(过去 30 天)
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 ?

采纳的回答

Walter Roberson
Walter Roberson 2012-3-19
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by