File Exchange

image thumbnail

relativepath.m

version 1.0 (2 KB) by

Convert path representations.

9 Downloads

Updated

View License

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 '..\'

Syntax:
rel_path = RELATIVEPATH( target_path, actual_path )

Comments and Ratings (9)

M. Luppi

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\'

Igor

Igor (view profile)

results in lowercase letters...

Lukas

Lukas (view profile)

David Zhang

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

David Zhang

David Zhang

Ano Nymous

worked fine, good examples

Changshun Deng

very good! many thanks!

MATLAB Release
MATLAB 6.0 (R12)

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

» Watch video