addpath and genpath duplicating the first part of chosen path

I'm trying to set up my file access for a script, but MATLAB's addpath and genpath functions keep duplicating the first part of the file path. This, obviously, throws an error, but I can't for the life of me understand why it does this. Has anyone else experienced a similar problem?
fullfile(pth{2}, fpth{1})
ans =
"Users/David/Library/CloudStorage/GoogleDrive-dblair@gsu.edu/My Drive/Calhoun/Functions"
addpath(fullfile(pth{2}, fpth{1}))
Warning: Name is nonexistent or not a directory: /Users/David/Library/CloudStorage/GoogleDrive-dblair@gsu.edu/My Drive/Calhoun/Users/David/Library/CloudStorage/GoogleDrive-dblair@gsu.edu/My Drive/Calhoun/Functions
> In path (line 109)
In addpath (line 96)

2 Kommentare

Can you show us the contents of these two parts of the two cell arrays?
pth{2}
fpth{1}
Yes, how did you get those? Did you do something like this:
p = genpath(pwd)
folders = strsplit(p, ';')

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Stephen23
Stephen23 am 27 Jan. 2026
Verschoben: Walter Roberson am 27 Jan. 2026

0 Stimmen

You are attempting to add absolute paths but are actually adding relative paths.

1 Kommentar

This is the correct answer. fullfile() does not prefix the input with leading '/'

Melden Sie sich an, um zu kommentieren.

try this example to understand the warning message in related to your input.
addpath("xyz")
Warning: Name is nonexistent or not a directory: /users/mss.system.4nfgz/xyz

Kategorien

Produkte

Version

R2025b

Gefragt:

am 27 Jan. 2026

Kommentiert:

am 28 Jan. 2026

Community Treasure Hunt

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

Start Hunting!

Translated by