MATLAB Community

MATLAB, community & more

Seeing What’s On the Search Path

I find the MATLAB search path to be one of the most difficult things to explain to new users. (The search path is what MATLAB uses to resolve function names to their code files). For the most part the search path contains the installed toolboxes, folders you’ve added through the Path Tool or addpath command, and the current directory.

In previous versions of MATLAB in order to know if a file is on the path, you could use the which command, or look at what folders are on the path with path or pathtool. In R2010a, we’ve added a path indicator to the current folder browser: files and folders not on the search path are now dimmed (see exaggerated example below).

Folders “use2” and “use3” and their contents are dimmed since they are not the MATLAB Search Path
Showing the dimmed files not on the path of MATLAB R2010a

With this information you can at a glance see if a folder and its contents are on the path or not. Many times I keep “parallel” projects with similar files/structures and sometimes I get confused about which one I’m working with or if a folder is on the path when I don’t expect it to be. This “on-the-path” knowledge along with the Current Folder Browser’s tree structure means I can tell just by looking.

As you can see in the next image, from the context menu you can not only add a folder and its subfolders quickly to the path (as before), but also remove a folder and its subfolders from the path and turn off the path indicator if you find it distracting or hard to read. Adding or removing folders from the path in this way does not persist between MATLAB sessions. Use pathtool or savepath to save the changes between MATLAB sessions.

Path manipulation on the current folder context menu

In case you’ve forgotten what a dimmed file or folder name means, we’re also providing this handy tooltip to explain it. And if you find the tooltip doubly distracting, we’ve got a “stop showing me this, already” button on there. We figure once you realize what it means, you’re not likely to forget.

Not on the path explanation tooltip

Finally, if you want to this feature to go away (or come back), or to adjust the visibility of the on-the-path indicator, you can do so from the Current Folder Preferences: File -> Preferences -> Current Folder.

Path indicator preferences
|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。