MATLAB: Do I get an error after adding a method to a class in MATLAB 7.7 (R2008b)

MATLAB

I created a class called MyClass, which is stored in a file as follows:
..\@MyClass\MyClass.m
Then I create a function called myfunction.m and store the file in the folder @MyClass. When I execute the following:
myObj = MyClass
myfunction(myObj)
I get the following error:
Undefined function or method 'myfunction' for input arguments of type 'MyClass'.
I need to restart MATLAB for the function call to work properly. I would like for MATLAB to be automatically able to detect the new functions.

Best Answer

The ability to automatically detect new functions or methods stored in separate files is not available in MATLAB 7.7 (R2008b).
To work around this issue, you have two options:
1. Declare the method signature within a methods block in the classdef block as specified in the 'Methods in Separate Files' section of the documentation found by executing the following at the MATLAB Command Prompt:
web([docroot '/techdoc/matlab_oop/brdqinq.html#brdqipw-1'])
For example:
classdef MyClass
methods (AttributeName = value,...)
tdata = myfunction(obj,arg1,arg2)
...
end % methods
...
end % classdef
2. After creating the function file, execute either of the following two commands to clear the class/function cache:
clear classes
clear functions