MATLAB Answers

What does @(x,y)myFunction mean?

318 views (last 30 days)
Kristoffer Walker
Kristoffer Walker on 2 Jul 2019
Commented: madhan ravi on 5 Jun 2020
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,


Sign in to comment.

Accepted Answer

Rik on 2 Jul 2019
Edited: Rik on 2 Jul 2019
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.


Show 1 older comment
Hershin Zarani
Hershin Zarani on 5 Jun 2020
then why is there (x,y) before @(x,y)disp()?
Steven Lord
Steven Lord on 5 Jun 2020
That indicates the anonymous function accepts two inputs and that inside the anonymous function the first is known as x and the second as y. See the anonymous function documentation page for more information.
madhan ravi
madhan ravi on 5 Jun 2020
Steven I think his question is why was it used for disp(...) when it doesn’t accept arguments x and y.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by