syntax of handle: f = @(X)find(X);
Show older comments
Hi everyone~
I'm learning about use handle. The usual syntax is h = @FuncName
But I also saw an example of f = @(X)find(X)
from here:
Can anyone please explain what the difference is? Can we use f = @find instead?
Thank you~
Accepted Answer
More Answers (1)
Matt J
on 24 Apr 2013
Briefly, you could use f=@find. The advantage of anonymous functions is that they allow you to point to functions which are not pre-packaged and which have more intricate forms. They can also take snapshots of other MATLAB workspace variables and use them as fixed parameters. E.g.,
a=1; b=2;
f=@(X) find(b*X>=a);
>> f([0,1,2])
ans =
2 3
1 Comment
Yuji Zhang
on 24 Apr 2013
Edited: Yuji Zhang
on 24 Apr 2013
Categories
Find more on Parallel Computing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!