What you probably want is to use a package, which is kind of like a python module in that it is a folder that can hold multiple files. You do this by putting a +
at the beginning of the folder name, like +mypackage
. You can then access the functions and classes in the folder using package.function
notation similar to Python without it polluting the global list of functions (only the package is added to the global list, rather than every function in it). You can also import individual functions or classes. However, you always have to use the full function path, there is no such thing as relative paths like in Python.
However, if you really want multiple functions per file, probably the best you can do is create a top-level function that returns a struct of function handles for the other functions in the file, and then access the function handles from that struct. Since MATLAB doesn't require the use of ()
with functions that don't require any inputs, this would superficially behave similarly to a python module (although I don't know how it will affect performance).
I know this is a pain in the neck. There is no reason mathworks couldn't allow using files as packages like they currently do for folders, such as by putting +
at the beginning of the file name. But they don't.