View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.5 | 8 ratings Rate this file 18 Downloads (last 30 days) File Size: 2 KB File ID: #3858 Version: 1.0



Jochen Lenz (view profile)


14 Aug 2003 (Updated )

Convert path representations.

| Watch this File

File Information

RELATIVEPATH returns the relative path from an actual path to the target path.

Both arguments must be strings with absolute paths. The actual path is optional, if omitted the current dir is used instead. In case the volume drive letters don't match, an absolute path will be returned.

If a relative path is returned, it always starts with '.\' or '..\'
       rel_path = RELATIVEPATH( target_path, actual_path )


This file inspired Fast And Efficient Spectral Clustering and Improved Relativepath.M.

MATLAB release MATLAB 6.0 (R12)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
13 May 2016 M. Luppi

13 Feb 2016 Igor

Igor (view profile)

One more bug - this function alway adds "\" on to the end of the result:

relativepath( 'c:\temp\1.txt', 'C:\temp') = '.\1.txt\'

06 Nov 2011 Igor

Igor (view profile)

results in lowercase letters...

20 May 2011 Lukas

Lukas (view profile)

16 Apr 2011 David Zhang

works great on mac, does it also work on windows?

Comment only
16 Apr 2011 David Zhang

16 Apr 2011 David Zhang

09 Feb 2010 Ano Nymous

worked fine, good examples

01 Nov 2005 Changshun Deng

very good! many thanks!

Contact us