How to make MATLAB recognize new static methods?

I use classes and static methods for scope functions in a namespace like C #. However, every time I add a new method to a class, it was not found at first. I have to restart MATLAB (2007a) to recognize new methods.

Of course, is there an “update” or “refresh” command that I can use, so I don’t need to restart the MATLAB environment every time I add a function?

+5
source share
3 answers

Calling this CLEAR call should do this:

clear classes

, , ( , MATLAB). , , , .

REHASH , ( , , ).a >

+6

.

, "MyClass" :

foo = MyClass;

, MyClass "bar":

foo.bar(); % Will cause error, as foo is instance of previous "MyClass"

, "clear" -ing foo :

clear('foo');
foo = MyClass; 
foo.bar(); % this should now work.

, . , script, :

varList = whos;
for iVar = 1:numel(varList)
    if isequal( 'MyClass', varList(iVar).class )
        clear( varlist(iVar).name );
    end
end
clear('varList');
clear('MyClass');

, , , script.

, .

+1

" "

0

All Articles