how to addpath of +folder

193 ビュー (過去 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 件のコメント
Brian C Coe
Brian C Coe 2015 年 2 月 18 日
編集済み: Brian C Coe 2015 年 2 月 18 日
when i try to open, edit, or find help for a file in one of these needlessly hidden folders matlab says it can't find it... despite the fact that the parent folder has been added to the path.
>> edit my_file
Error using edit (line 61)
Neither 'my_file' nor 'my_file.m' could be
found.
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 件のコメント
Ralph
Ralph 2020 年 2 月 29 日
The critical issue is twofold:
(1) The '+' indicator means it is a package folder
(2) packages in Matlab are a broken cludge
Functions within a package can not call one another unless every single one of them features the import function. And that import must have the name of the package. So you can't just put a bunch of related files in a package and be done. You have to go through every file and add the import command. Which is to say - packages in Matlab are a broken cludge.
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 件のコメント
Brian C Coe
Brian C Coe 2015 年 2 月 18 日
um, no it doesn't get automatically added.
i say that because when i try to open, edit, or find help for a file in one of these needlessly hidden folders matlab says it can't find it... despite the fact that the parent folder has been added to the path.
>> edit my_file
Error using edit (line 61)
Neither 'my_file' nor 'my_file.m' could be
found.
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by