genpath() function doesn't return path names of all subfolders

Hi,
I deal with a weird problem of MATLAB 2012a in MAC.
I used genpath() function to get the path names of subfolders in a folder. However, the results don't include all existing subfolders.
Do you know what problem it is? And how to fix it?
Thank you very much.

Réponses (2)

Steven Lord
Steven Lord le 16 Mar 2017
Which subfolders are missing from the path? There are certain directories that are not allowed to be on the path, and genpath will not list them. From the documentation for this function in release R2012a:
"The path string does not include folders named private or folders that begin with the @ character (class folders) or the + character (package folders)."

5 commentaires

Hi Steven Lord,
Thank you for your answer.
There is no specific symbols in the path names.
And you know, I used to use genpath function to generate the path names without any error (in startup.m). One day, it couldn't generate all path names in a folder, and I couldn't find the reason so far :(.
This is going to require more information about the name of the folder and what's in it. Since I'm guessing you won't want to post that here I recommend contacting Technical Support, providing them with that information, and ask them for help determining why genpath isn't listing all the directories you expect it should.
Since you're using a 5 year old version, I believe you don't have a maintenance contract or support, so you'll have to list your folders here if that's the case, and hope someone with a Mac can help you.
Hi,
I want to add the mrVista (stored in /Users/Documents/toolbox) toolbox into MATLAB. I type genpath('/Users/Documents/toolbox/mrVista') in the MATLAB command window, then get result as a string of paths that are directories of subfolders inside the mrVista folder. However the result is not the list of all subfolders' paths. E.g. it lacks the /Users/Documents/toolbox/mrVista/fileFilters/nifti path, which apparently exists in my MAC :(.
This is a job for the debugger: Set a breakpoint in the fist line of genpath and step through the code line by line. Perhaps you have appended user-defined folders on top of the path and Matlab uses a function, which shadows a built-in function. What ever it is, the debugger let you find out the details.

Connectez-vous pour commenter.

Try
addpath(genpath('/Users/Documents/toolbox/mrVista'));
% Optional save for future sessions:
savepath;
Is /Users/Documents/toolbox/mrVista/fileFilters/nifti a hidden folder?

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by