from
mypath.m
by Malcolm Wood
Displays or returns the MATLAB path, omitting directories which are inside the MATLAB "toolbox" ...
|
| mypath
|
function p = mypath
%MYPATH Returns the current MATLAB path, excluding toolboxes
%
% path % prints to command window
% p = mypath
%
% "p" is a cell array of strings
% Copyright 2006-2010 The MathWorks, Inc.
% We'll ignore directories inside this one
toolboxroot = fullfile(matlabroot,'toolbox');
% Get the complete MATLAB path. This will be a semi-colon separated string
fullpath = path;
% Tokenize it.
tokenized = strread(fullpath,'%s','delimiter',pathsep);
% Identify entries on the path which are inside the "toolbox" directory
match = strncmpi(tokenized,toolboxroot,length(toolboxroot));
% Select those directories outside the "toolbox" directory.
dirs = tokenized(~match);
if ~nargout
% No outputs requested. Print the results.
fprintf(1,'Non-toolbox directories on MATLAB path:\n');
fprintf(1,' %s\n',dirs{:});
else
% Return the results.
p = dirs;
end
|
|
Contact us at files@mathworks.com