addPath does not take a vector from genpath

2 vues (au cours des 30 derniers jours)
Richard Frei
Richard Frei le 20 Nov 2022
Commenté : Jan le 21 Nov 2022
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?

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Search Path dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by