"Undefined function" errors are commonly not because of the wrong type of input argument, but because MATLAB can't find the file. To call a function it should be:
- In an *.m file with the same name as the function (e.g.
myfunc.m
for function myfunc
)
- In the current working folder or on the MATLAB path, which tells MATLAB where to look for files.
Normally when installing a MATLAB toolbox it will automatically be added to the path, but third-party toolboxes often need to be manually added. Make sure you add all subdirectories as well. You can do this using genpath
in addition to addpath
:
addpath(genpath('c:/matlab/mytoolbox'))
There is also a graphical interface for changing the MATLAB path, accessible from the commandline by typing pathtool
. Again, for a toolbox, use "Add with Subfolders".