フィルターのクリア

Help understand: Passing a function handle to another function as an argument

2 ビュー (過去 30 日間)
KAE
KAE 2017 年 6 月 9 日
コメント済み: KAE 2017 年 6 月 13 日
Can you help me understand the following line in the program GUI_27 from the file exchange?
set(S.fh,'windowbuttonmotionfcn',{@fh_wbmfcn,S})
I know @ is a handle to a separately defined function called fh_wbmfcn, but am puzzled about what the {} brackets are doing. Are they passing in S as an input to fh_wbmfcn? I have never seen this syntax before and it is hard to search the documentation for characters like @ or {}.
[Note GUI_27 is part of the very useful set of GUI examples by Matt Fig.]

採用された回答

Walter Roberson
Walter Roberson 2017 年 6 月 9 日
Remember that every graphics callback is automatically passed two initial arguments: the source and the event data. Using the cell array {@fh_wbmfcn,S} has the same effect as if you had specified @(src,event) fh_wbmfcn(src, event, S)
  3 件のコメント
Walter Roberson
Walter Roberson 2017 年 6 月 9 日
"Is it possible to pass the output arguments of fh_wbmfcn which are Cx, Cy to the workplace of function that calls it"
Sorry, no, callbacks are never invoked with output assigned. Callbacks are executed as if called from the base workspace, because they are invoked asynchronously. Functions do not call callbacks (but functions might define callbacks.)
KAE
KAE 2017 年 6 月 13 日
Thanks, that is helpful info.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by