What is the benefit of using a function handle?
1 次查看(过去 30 天)
显示 更早的评论
y = @(x) x; vs y=x... why would I use one over the other? Any benefit to the function handle?
0 个评论
采纳的回答
per isakson
2015-1-24
IMO: the main benefit is that it can be passed to other functions as an argument.
0 个评论
更多回答(2 个)
Zoltán Csáti
2015-1-24
The two statements are not the same. The first one defines a function while the second one is an equality. The two identical forms are
y = @(x) x;
and
function y = some_function(x)
y = x;
end
0 个评论
Kai
2015-1-24
The function handle is for example helpful for integration. Maybe you can have a look at fplot, which makes use of function handles.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!