获取path路径中的文件夹

function [folderLen,folder]=getFolder(path)
% dir函数获得文件夹的数目

lists=dir(path);   % 全部文件及文件夹列表
lists(1:2)=[];
% folder=[];
n=1;

for index=1:length(lists)
    if lists(index).isdir==1
        folder(n)=lists(index);
        n=n+1;
    end
end
folderLen=length(folder);

end

猜你喜欢

转载自blog.csdn.net/pugao23/article/details/83214739