What is the benefit of using a function handle?
조회 수: 7 (최근 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!