Wrong varargin when calling memoized functions saved in a handle class as constant properties
3 views (last 30 days)
I have a handle class named as "MemoizedFunctionClass" to save all the memoized functions as its constant properties and it is coded in a single file in my work dir, like the following one:
classdef MemoizedFunctionClass < handle
MemoizedAdd = memoize(@add)
function c = add(n, k)
c = n + k;
Meanwhile, in the same dir I have a script file in which I want to execute my memoized functions. I find that I cannot execute the memoized function "MemoizedAdd" properly when accessing it directly using class dot notation "MemoizedFunctionClass.MemoizedAdd(1, 1)". It seems that only one argument is passed into that memoized function object (One can enter debug mode to check this) thus triggering an error message saying "Not enough input arguments."
% Error: Not enough input arguments.
But if I first assign the memoized function to an intermediate variable, it works fine:
mAdd = MemoizedFunctionClass.MemoizedAdd;
% No error occurs
I also noticed that if I use the dot notation in the command line window, it also works fine:
>> MemoizedFunctionClass.MemoizedAdd(1, 1)
So is this a bug or do I mistake the usage of classes or memoized functions in MATLAB? Any suggestions or solutions are appreciated.