1
簡約例子:變換等功能處理,以其他同等功能的處理
classdef MyClass
properties
arr
handArr
end
properties(Dependent)
rowAcc
colAcc
end
methods
function obj = MyClass(arr, handRow, handCol)
obj.arr = arr;
obj.handArr{1} = handRow;
if ~isequal(handRow, handCol)
obj.handArr{2} = handCol;
end
end
function r = get.rowAcc(obj)
r = obj.handArr{1}(obj.arr);
end
function c = get.colAcc(obj)
c = obj.handArr{end}(obj.arr);
end
end
end
現在假設我通過平等函數的構造,我想Row和Col訪問也將是相同的:
[email protected](x)@(y) y;
x=MyClass(1, f, f);
isequal(x.rowAcc, x.colAcc) //should be 1
這可能嗎?
我對這個「瘋狂」的要求的原因是:
我已與輸入的宏塊100+運行,並採取這兩個函數作爲輸入,並且幾種算法當它們相等時,他們可以很優化有效率的;調用我需要對這個類中封裝的輸入函數進行轉換的算法。我無法更改算法(不是我的代碼),他們使用isequal
來分配他們自己的函數。
再次感謝您的另一個偉大的答案! –