I need to list the subfolders inside a folder using Matlab. If I use
nameFolds = dir(pathFolder),
I get . and .. + the subfolder names. I then have to run nameFolds(1) = [] twice. Is there a better way to get the subFolder names using Matlab? Thanks.
Use
isdirfield ofdiroutput to separate subdirectories and files:You can then remove
.and..You shouldn’t do
nameFolds(1:2) = [], sincediroutput from root directory does not contain those dot-folders. At least on Windows.