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 Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by