Code covered by the BSD License  

Highlights from
Generate help files from m-files

image thumbnail
from Generate help files from m-files by Wolfgang Garn
Help files are generated from m-files.

getDirs(abs_file)
function dirs = getDirs(abs_file)
% getDirs   Returns the path of the file including the slash or backslash.
% The directories (path) including the slash or backslash of the file is
% returned.
% Note that there is no check whether the file exists.
%
% Example
%+  getDirs('C:\MATLAB704\work\publish\wg_publish.m')
%
% See also: getFileName, allSlashes
%
%% Signature
% Author: W.Garn
% E-Mail: wgarn@yahoo.com
% Date: 2005/12/01 20:00:00 
% 
% Copyright 2005 W.Garn
%
    Ib = strfind(abs_file,'\');
    Is = strfind(abs_file,'/');
    I = union(Ib,Is);
    if ~isempty(I)
        dirs = abs_file(1:max(I));
        dirs(I) = '/'; % replace backslahs by slash
    else
        dirs=[];
    end

Contact us at files@mathworks.com