Lack of function_handle arrays
댓글 수: 5
답변 (2개)
Suppose you have
f = @(x)x+1
then what is
f(1)
?
If hypothetically matlab supported function handle arrays then because every scalar is an array of size 1 then it would follow that f(1) would refer to the first function handle in the array and so would be that handle to @(x)x+1 . But function handle invocation is also () so it would also mean invoking the handle with parameter 1
Or are you proposing that the meaning of () indexing of a function handle array would depend upon whether it was nonscalar? If so then how would you pass a single function handle to code that expected an array of function handles?
There is a fundamental clash in semantics if you permit nonscalar function handle arrays, and the only way out would be to change matlab to use different syntax for invocation compared to indexing. Which would cause its own problems.
참고 항목
카테고리
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!