addPath does not take a vector from genpath

4 ビュー (過去 30 日間)
Richard Frei
Richard Frei 2022 年 11 月 20 日
コメント済み: Jan 2022 年 11 月 21 日
Hi.
Im trying to create a Project with the help of a scripts/funktions. The creation works fine, just my code for adding the folders in the Root don't work.
I have the this funktion
function [] = ProjektFolderAdd(folder)
addFolderIncludingChildFiles(currentProject,folder);
addPath(currentProject,genpath(fullfile(pwd,folder)));
end
And i call it like this from a batch file
mkdir Code_Generation
mkdir Simulations_Cachs
mkdir Parameter
mkdir Models
mkdir Models\First_Refrenz_Model
mkdir Models\Second_Refrenz_Model
mkdir Models\General_Purpose_Subsystem
matlab.exe -r "cd C:\Users\Asus\Desktop\code_versuche\Repo_batch\teset2\,
run ('ProjektSetup()'),ProjektFolderAdd('Code_Generation'), exit"
"cd" and "run ('ProjektSetup()')" works, just not the "ProjektFolderAdd('Models')" part.
Models is a folder in the Root of the Projekt and has 3 subfolders.
No folder in the whole path has a space in it and when i pass
addpath(genpath(fullfile(pwd,folder)));
like this it works but will not be a part of the Project.
Error using matlab.project.Project/addPath
The file or folder
"C:\Users\Asus\Desktop\code_versuche\Repo_batch\teset2\Models;C:\Users\Asus\Desktop\code_versuche\Repo_batch\teset2\Models\First_Refrenz_Model;C:\Users\Asus\Desktop\code_versuche\Repo_batch\teset2\Models\General_Purpose_Subsystem;C:\Users\Asus\Desktop\code_versuche\Repo_batch\teset2\Models\Second_Refrenz_Model;"
does not exist.
Error in ProjektFolderAdd (line 5)
addPath(currentProject,genpath(fullfile(pwd,folder)));
Am I missunderstanding how addPath and addpath works or is the vektor from genpath diffrent from what i need?

採用された回答

Jan
Jan 2022 年 11 月 20 日
According to the documentation https://www.mathworks.com/help/matlab/ref/matlab.project.project.addpath.html addPath() takes one folder as input, not the output of genpath.
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 11 月 20 日
genpath is for creating MATLAB path entries, and is used with addpath -- notice the lower-case 'p' . That is a different function than addPath that is for working with projects.
Jan
Jan 2022 年 11 月 21 日
@Walter Roberson: Exactly. While addpath() accepts the output of genpath(), addPath() does not.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by