addPath does not take a vector from genpath

2 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Jan
Jan il 20 Nov 2022
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 Commenti
Walter Roberson
Walter Roberson il 20 Nov 2022
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 il 21 Nov 2022
@Walter Roberson: Exactly. While addpath() accepts the output of genpath(), addPath() does not.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Search Path in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by