getsubdirs.m

来自「FKNN:模糊KNN分类算法」· M 代码 · 共 28 行

M
28
字号
function dirlist = getsubdirs(dirname)
%GETSUBDIRS Recursively get all subdirectories of a directory

% Copyright 2003

fs = filesep;

files = dir(dirname);
subdirs = files(logical([files.isdir]));

dirlist = {dirname};
%  ~strcmp(this,'..') strcmp(this(1),'h')

if ~isempty(subdirs)
    for n = 1:length(subdirs)
        % Short circuit directories on the stop list
        this = subdirs(n).name;
        if      ~strcmp(this(1),'@') && ...
                ~strcmp(this,'.') && ...
                ~strcmp(this,'..')
            dirlist = [dirlist; ...
                getsubdirs([dirname fs this])];
            % disp([dirname filesep this])
        end
    end
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?