how to addpath of +folder

198 views (last 30 days)
nt on 9 Oct 2014
Commented: Hyunuk Ha on 13 Jul 2021
when I add path like
it shows
Warning: Package directories not allowed in MATLAB path:
Can I know how to solve it?
Thierry Dalon
Thierry Dalon on 30 Jul 2015
MATLAB sees these functions as myfolder.my_file (taking your example).

Sign in to comment.

Answers (6)

Steve on 5 Sep 2018
You have to use the syntax folder.mfile(vars), where "folder" is the folder name with the "+" before it and "mfile" is the function.

Al in St. Louis
Al in St. Louis on 2 Nov 2017
None of these answers actually helps.
Syed Mubashir Azeem Bukhari
this seems logical, can you give an example please?

Sign in to comment.

SK on 9 Oct 2014
Edited: SK on 9 Oct 2014
Matlab does not allow you to add class directories or package directories individually to the path.
You have to add the parent directory instead and the class/package directory then gets automatically added.
Adam on 19 Feb 2015
Trying to edit a file from command line is a different action from Matlab being able to find the code to run the functions.
Having a package parent folder added to the path allows the latter, but for the former you will likely have to give a full path or path relative to your working directory because the package folders are not themselves on the path.

Sign in to comment.

YIN JEH NGUI on 11 Jun 2016
This is due to "+" symbol in your folder name. Change it and you can add it. I faced the same issue and can only ammend the folder name for addpath to work. Bugs maybe?
  1 Comment
Adam on 13 Jun 2016
The + defines that the folder is a package. Without it the folder is no longer a package so getting rid of it will not be helpful at all.

Sign in to comment.

Muhammad Usman Saleem
Muhammad Usman Saleem on 11 Jun 2016
pwd('your directory path')

Hyunuk Ha
Hyunuk Ha on 13 Jul 2021
You should 'import' package directory, not 'addpath'.
So, basically you may use pkg dir. as
>> mypkg.myfile(in)
but after import pkg dir.
>> import mypkg
then, you can use,
>> myfile(in)
package directory can't be add to the path, but you can import it.
Please refer to :
  1 Comment
Hyunuk Ha
Hyunuk Ha on 13 Jul 2021
You may know (explicitly) imported pkg dir. has high priority than other public methods or built-in fcn.

Sign in to comment.


Find more on Search Path in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!