Let's define the following class with some nested methods:
classdef MyClass
methods(Static)
function a = simple_func(obj)
a = obj.simple_func2(1);
end
function b = simple_func2(obj,arg1)
b = arg1+1;
end
end
end
And call a class method as follow:
c = MyClass
a = c.simple_func()
I get the following error:
Not enough input arguments.
Error in MyClass.simple_func (line 4)
a = obj.simple_func2(1);
Error in main (line 2)
a = c.simple_func();
What is the issue with my class definition? I read so much Matlab documentation that I'm lost now. I use MATLAB 2023b.
You've defined the methods as
Static
, which means thatc.simple_func()
doesn't callsimple_func(c)
, but justMyClass.simple_func()
. If you remove theStatic
declaration, it'll work as intended.