how to addpath of +folder

조회 수: 234(최근 30일)
nt
nt 2014년 10월 9일
댓글: Hyunuk Ha 2021년 7월 13일
when I add path like
addpath('C:\+myfolder')
it shows
Warning: Package directories not allowed in MATLAB path:
Can I know how to solve it?
  댓글 수: 3
Thierry Dalon
Thierry Dalon 2015년 7월 30일
MATLAB sees these functions as myfolder.my_file (taking your example).

댓글을 달려면 로그인하십시오.

답변(6개)

Steve
Steve 2018년 9월 5일
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 2017년 11월 2일
None of these answers actually helps.
  댓글 수: 6
Syed Mubashir Azeem Bukhari
Syed Mubashir Azeem Bukhari 2021년 5월 17일
this seems logical, can you give an example please?

댓글을 달려면 로그인하십시오.


SK
SK 2014년 10월 9일
편집: SK 2014년 10월 9일
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.
  댓글 수: 2
Adam
Adam 2015년 2월 19일
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.

댓글을 달려면 로그인하십시오.


YIN JEH NGUI
YIN JEH NGUI 2016년 6월 11일
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
Adam
Adam 2016년 6월 13일
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.

댓글을 달려면 로그인하십시오.


Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 6월 11일
use
pwd('your directory path')

Hyunuk Ha
Hyunuk Ha 2021년 7월 13일
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 :
https://www.mathworks.com/help/matlab/ref/import.html?searchHighlight=import&s_tid=doc_srchtitle
  댓글 수: 1
Hyunuk Ha
Hyunuk Ha 2021년 7월 13일
You may know (explicitly) imported pkg dir. has high priority than other public methods or built-in fcn.
https://www.mathworks.com/help/matlab/matlab_prog/function-precedence-order.html

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by