addPath does not take a vector from genpath

2 views (last 30 days)
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?

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on Search Path in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!