Home
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: Genpath()

Ken,

I am very thankful! It works wonderfully. Just what I have been looking
for...

Roy

Ken Davis wrote:

> "Roy S Schestowitz"
>
<roy-dot-schestowitz-at-isbe-dot-man-dot-ac-dot-uk@use-address-before-at.com
>> wrote in message ceqog6$17m2$1@godfrey.mcc.ac.uk">news:ceqog6$17m2$1@godfrey.mcc.ac.uk...
>> Hi all,
>>
>> When I use genpath() I get a string output which is the sub-directories
> with
>> a ':' delimiter. For example,
>>
>> .:./example:./example/subdir1:./example/subdir2
>>
>> Is there an easy way to convert this string into an array of directories?
> I
>> need to feed it to another function in an array form.
>>
>> Thanks very much,
>>
>> Roy
>>
>> PS - A note to the MATLAB developers - is it really good practice for
>> addpath() to take a string of this form?
> 
> function p = pathlist(R)
> % PATHLIST(R) Returns path R or current path as a cell array. The
> delimiter is the value
> % returned by the pathsep function.
> % USAGE: p = pathlist(genpath);
> 
> % Initialize to the current path.
> if nargin < 1
>     R = path;
> end
> 
> % Remove trailing path separator, if any.
> if ~isempty(R)
>     if isequal(R(end), pathsep)
>         R = R(1:end-1);
>     end
> end
> 
> p = strread(R, '%s', 'delimiter', pathsep); % Use generic parse function.



  • References:
    • Genpath()
      • From: Roy S Schestowitz <roy-dot-schestowitz-at-isbe-dot-man-dot-ac-dot-uk@use-address-before-at.com>
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index