Add a class folder to path

17 ビュー (過去 30 日間)
Laila
Laila 2025 年 3 月 10 日
編集済み: Matt J 2025 年 3 月 10 日
I want to add a class folder with its subfolders using command>> addpath(('C:\Program Files\MATLAB\R2023b\toolbox\pde\+pde')); but I get the following messege
Warning: Method directories not allowed in MATLAB path: C:\Program Files\MATLAB\R2023b\toolbox\pde\+pde\@PDEModel
> In path (line 109)
In addpath>doPathAddition (line 116)
In addpath (line 80)
  1 件のコメント
Matt J
Matt J 2025 年 3 月 10 日
編集済み: Matt J 2025 年 3 月 10 日
Is there a reason you are manually addpath()-ing native Matlab file folders? Those should have been properly set in the path by the Matlab installer, and shouldn't require your intervention. It seems inadvisable to tamper with them.

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

回答 (1 件)

Matt J
Matt J 2025 年 3 月 10 日
編集済み: Matt J 2025 年 3 月 10 日
Nothing is wrong. @-directories should not and do not need to be on the path as long as their parent directory is.
You can automatically exclude such sub-folders by doing,
>>addpath(genpath(parentFolder))
  1 件のコメント
Steven Lord
Steven Lord 2025 年 3 月 10 日
It's stronger than "should not and do not" -- from the documentation page describing what the MATLAB search path is:
"Class, namespace, private, and resources folders are special folders that cannot be specified explicitly as part of the search path. A special folder is added to the search path implicitly when its parent folder is specified as part of the path. To access the files and folders within a special folder, you must add its parent folder to the path."

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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by