Okay, so I just worked it out. I'll summarize the solution here for anyone else who's had this problem.
For the sake of reference, you can find the relevant material by searching for, "A Simple Class", in Documentation.
In short, for normal non-static methods, you have to add a reference object as the first argument of the argument list, or as the only argument when a method would normally not take any arguments.
So for example, if you wanted a simple method that offered no return value, and took no input arguments, then the method deceleration would look something like this, where the argument "obj" is the reference argument, which needs to be included, even if you are not going to use it.
ClassX.m
classdef ClassX
methods
function foo ( obj )
fprintf ( 'Hello World!\n' );
end
end
end
The method "foo", can be called as follows, with out any arguments.
Command Window
>> x = ClassX;
>> x.foo;
Hello World!
>>
Then, if you want actual arguments, you might do something like this, including the object reference as the first argument, even if you are not going to use it.
ClassX.m
classdef ClassX
methods
function foo ( obj, message )
fprintf ( message );
fprintf ( '\n' );
end
end
end
Then "foo", could be called with one argument as follows.
Command Window
>> x = ClassX;
>> x.foo ( 'Hello World!' );
Hello World!
>>
For multiple arguments and return values, you follow the same pattern. Just include an object reference as the first argument in the argument list, followed by all your 'actual' arguments.
ClassAdd.m
classdef ClassAdd
methods
function y = add ( obj, a, b )
y = a + b;
end
end
end
Command Window
>> f = ClassAdd;
>> f.add ( 1, 1 );
ans =
2
>>