function to wait for a variable to change value

조회 수: 8 (최근 30일)
XIAOJUN BAO
XIAOJUN BAO 2011년 10월 21일
waitfor(h,'PropertyName') as this syntax blocks the caller from executing until the value of 'PropertyName' (any property of the graphics object h) changes or h closes (is deleted), Is there any similar syntax that can suspend the command and wait until a variable changes its value?
Thanks!

답변 (1개)

Walter Roberson
Walter Roberson 2011년 10월 21일
It took me a bit of time to come up with a mechanism by which such a situation could happen at all (if one leaves out parallel processing.)
In every case I have been able to think of, there has to be a callback involved (whether handle graphics or timer or serial object or the like.) Without parallel processing, callbacks are the only mechanism to (however temporarily) get a second thread going that can do independent work such as changing a variable. And if you are going to have a callback involved, one might as well wait on a graphics object property that stands proxy for the variable being changed.
For example, in various callbacks, one might have
set(0,'UserData','X71_Updated');
set(0,'UserData','Theta_Updated');
set(0,'UserData','23Skidoo_Updated');
and then at a point where you were interested in knowing that your variable had changed, you could
waitfor(0,'Userdata','23Skidoo_Updated');

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by