What does @(x,y)myFunction mean?

154 ビュー (過去 30 日間)
Kristoffer Walker
Kristoffer Walker 2019 年 7 月 2 日
編集済み: Stephen23 2021 年 12 月 20 日
Folks,
Could someone please point me to documentation that explains what the "@(x,y)" means in the below code?
@(x,y)disp('Hello World!')
Similarly, what do the following mean?
StartFcn = @(~,~)myfile
StartFcn = @myfile
StartFcn = {@myfile, 5, 6}
I am trying to get a timer to execute a specific callback in a GUIDE GUI. In order to get this to work, it seems I really need to understand that syntax.
Thank you,
Kris

採用された回答

Rik
Rik 2019 年 7 月 2 日
編集済み: Rik 2019 年 7 月 2 日
The @ symbol generates either a function handle or creates an anonymous function.
You can read more on this doc page.
You third syntax is slightly less obvious. For that one you can find more information here.
  6 件のコメント
Omar Alamoudi
Omar Alamoudi 2021 年 12 月 20 日
I would like to know the name to the question stated by @madhan ravi
Stephen23
Stephen23 2021 年 12 月 20 日
編集済み: Stephen23 2021 年 12 月 20 日
@Omar Alamoudi: because that anonymous function (and indeed all of the other examples shown in the original question) was written as a callback function for a GUI:
If those two input arguments (object and event) are not used, then they can be ignored, as in that example, but they still need to be defined. It would be better to use tildas for this, which makes the intent clearer.
The code is basically a hello-world callback function.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCode Execution についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by