Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I'd like to organize my Matlab packages into folders. However, if I try to lay out my code like this +MyPackage |---foo.m |---SubDir |---bar.m then I'm unable to reach bar. F...
Question
matlab
#1: Initial revision
Can Matlab packages have subdirectories?
I'd like to organize my Matlab packages into folders. However, if I try to lay out my code like this ```none +MyPackage |---foo.m |---SubDir |---bar.m ``` then I'm unable to reach bar. For example, if the contents of foo.m are ```matlab function foo disp("foo") bar end ``` and the contents of bar.m are ```matlab function bar disp("bar") end ``` then running `MyPackage.foo` outputs ```none foo Error using bar Not enough input arguments. Error in MyPackage.foo (line 3) bar ``` Trying to add SubDir with `addpath` gives a warning that package directories are not allowed in the MATLAB path. Does everything in a Matlab package really need to be within a single directory, or is there a way to organize packages with subdirectories?