File Exchange

image thumbnail

Check whether directory is on current MATLAB path

version 1.1.0.0 (2.76 KB) by Rody Oldenhuis
Small low-level utility to check whether (list of) directories is/are on the current search path

3 Downloads

Updated 17 Aug 2015

GitHub view license on GitHub

ISONPATH checks if given directory is on the current MATLAB path. Vectorized in the sense that it accepts cell-arrays of strings.
y = ISONPATH(dirs) for string [dirs] checks whether the specified directory is on the MATLAB search path. The output [y] is a logical scalar equal to 'true' when the directory is on the path, 'false' otherwise.

In case [dirs] is a cell array of strings, the same check is performed for each entry in [dirs]. In this case, the output [y] is a logical array the same size as [dirs].

Note that a case-INsensitive comparison is used on windows platforms, while exact case match is required for Linux/Mac platforms.

Comments and Ratings (4)

@JanSimon: thanks for the heads up, I really should check this stuff more carefully.

Jan

You define the license as: "GPL + anything implied by placing it on the FEX". But the BSD license required for the FEX and GPL are not compatible. This legal stuff is bewildering.

@Thierry: that is true, but have a look at 'edit ismember'... It's basically a much more complicated version of my little loop. I went for the simpler solution.

For windows this could be shortened/vectorized to the 2 lines:
pathcellstr=regexp(path,';','split');
tf=ismember(dirs,pathcellstr);

Updates

1.1.0.0

[linked to Github]

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux