Compare Handles to Nested Functions
MATLAB considers function handles to the same nested function to be equal only if your code
constructs these handles on the same call to the function containing the nested function. This
function constructs two handles to the same nested function.
function [h1,h2] = test_eq(a,b,c)
h1 = @findZ;
h2 = @findZ;
function z = findZ
z = a.^3 + b.^2 + c';
end
end
Function handles constructed from the same nested function and on the same call to the parent
function are considered equal.
[h1,h2] = test_eq(4,19,-7);
isequal(h1,h2)
ans =
logical
1
Function handles constructed from different calls are not considered equal.
[q1,q2] = test_eq(4,19,-7);
isequal(h1,q1)
ans =
logical
0
See Also
isequal
Related Examples
•
“Create Function Handle” on page 13-2
Compare Function Handles
13-9
MATLAB considers function handles to the same nested function to be equal only if your code
constructs these handles on the same call to the function containing the nested function. This
function constructs two handles to the same nested function.
function [h1,h2] = test_eq(a,b,c)
h1 = @findZ;
h2 = @findZ;
function z = findZ
z = a.^3 + b.^2 + c';
end
end
Function handles constructed from the same nested function and on the same call to the parent
function are considered equal.
[h1,h2] = test_eq(4,19,-7);
isequal(h1,h2)
ans =
logical
1
Function handles constructed from different calls are not considered equal.
[q1,q2] = test_eq(4,19,-7);
isequal(h1,q1)
ans =
logical
0
See Also
isequal
Related Examples
•
“Create Function Handle” on page 13-2
Compare Function Handles
13-9
