File Exchange

image thumbnail

parentpath - returns the path shared by multiple subpaths

version 1.1.0.0 (1.95 KB) by Bob Spunt
Returns the filesystem path shared by multiple subpaths

2 Downloads

Updated 03 Nov 2016

View Version History

GitHub view license on GitHub

Simple utility to return the parent path shared by multiple input subpaths.
USAGE: parpath = parentpath(subpaths)

Cite As

Bob Spunt (2020). parentpath - returns the path shared by multiple subpaths (https://github.com/spunt/parentpath), GitHub. Retrieved .

Comments and Ratings (1)

Chang hsiung

sf={'C:\work';'C:\work\JDSU\ModelsTransferMLtool\Results\Pest';'C:\work\JDSU\ModelsTransferMLtool\TestSite_IDRC\cmp_CTCP\KS5'};
[parpath, branchpar] = ParentPath(sf)
%-------------------------------------
when I ran the above, I got error:

Index exceeds matrix dimensions.

Error in ParentPath>@(x)x(2) (line 47)
branchpar = cellfun(@(x) x(2), tmp);

Error in ParentPath (line 47)
branchpar = cellfun(@(x) x(2), tmp);

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!