Code covered by the BSD License  

Highlights from
mypath.m

4.0

4.0 | 2 ratings Rate this file 4 Downloads (last 30 days) File Size: 1.54 KB File ID: #10371

mypath.m

by Malcolm Wood

 

16 Mar 2006 (Updated 23 Feb 2010)

Displays or returns the MATLAB path, omitting directories which are inside the MATLAB "toolbox" ...

| Watch this File

File Information
Description

Those of us who have a lot of The MathWorks' toolboxes find that every time we type "path" at the MATLAB command line, we have to scroll up several pages before we find what we're looking for.

Since most of the time we're interested in our own working directories, and since most of us don't do our work in directories under $matlabroot/toolbox, this function prints the (hopefully much shorter) list of directories which are on the MATLAB path but aren't inside $matlabroot/toolbox.

Just type:
>> mypath
to see those directories.

Alternatively, if you want to do something with the result, type:
>> p = mypath
to get the same list as a cell array of strings.

Acknowledgements
This submission has inspired the following:
exportToZip: Identifies the dependencies of an M-file and creates a ZIP file, exporttozip
MATLAB release MATLAB 6.1 (R12.1)
Other requirements Should work in any version of MATLAB and any platform, though I have only tested on Windows and back as far as R12.1
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
20 Mar 2006 John D'Errico

This could be interesting but disappointingly, its not system independent. It assumes the path separator is a semicolon. Since the fix is trivial, why not make it fully flexible?

help pathsep

22 Mar 2006 Malcolm Wood

Good point. Now uses pathsep, hopefully making it platform independent.

26 Mar 2006 John D'Errico

This looks good now. I like the use of nargout to differentiate between returning an argument and just displaying to the command window.

Minor points (that I should have caught the first time) - the help refers to USERPATH in one spot, but the function name is MYPATH. It should also document the fact that when no output argument is provided, it only displays to the command window. Otherwise a user might be confused.

11 Mar 2011 Mark Morehead

This is an excellent routine to archive your work or share your work with others.

My mfiles are spread across my local hard drive and a couple of network drives. So the absolute paths and rootpath in exportToZip did not work. I created a new version "exporttozip" that uses either relative or absolute paths.

I did not know how to directly update the exportToZip file on file exchange so I submitted a new file called exporttozip. Although it is listed as my submission, Malcolm Wood should really get the credit for it.

Please login to add a comment or rating.
Updates
21 Mar 2006

Response to suggestion. Now uses pathsep instead of hardcoded semi-colon.

17 Dec 2009

Review

23 Feb 2010

Added copyright line.

Tag Activity for this File
Tag Applied By Date/Time
path Malcolm Wood 22 Oct 2008 08:18:42
directories Malcolm Wood 22 Oct 2008 08:18:42
files Malcolm Wood 22 Oct 2008 08:18:42
directory Malcolm Wood 22 Oct 2008 08:18:42
paths Malcolm Wood 22 Oct 2008 08:18:42
directory Julian 16 Oct 2009 07:07:36

Contact us at files@mathworks.com