I define a class CellArrayHandle whose only property is a cell array of function handles:
classdef CellArrayHandle < handle
properties
cel % cell array of function handles
end
end
Suppose myHandle is an object of CellArrayHandle, so myHandle.cel is a n-by-1 cell array of function handles, i.e myHandle.cel{i} is a function handle for i = 1 to n.
I want to do some update (for e.g. i=1), but the following does not work:
myHandle.cel{1} = @(x) myHandle.cel{1}(x) + 0.5;
Matlab says "Maximum recursion limit of 500 reached", so it seems to be understood as an infinite recursion. However the fowllowing works:
f = @(x) f(x) + 0.5;
for a function handle f.
It seems when I encapsulate a function handle into a class as a property, the above update method will not work.
I do not understand the difference between the former and the latter. Could any people help me on this point? Thank you very much.
Best regards,
Frank