Using dir function in Matlab - how to get rid of `.` and `..`

dir, directory, file-io, matlab

Solution

I don't know of any built-in solution, but I tend to do the following:

d = dir ('C:\');
d(~[d.isdir])= []; %Remove all non directories.
names = setdiff({d.name},{'.','..'});

The `setdiff` command removes the unwanted elements.

Another cheap way to get rid of `.` and `..` is using wildcards (Windows only):

d = dir ('C:\*.*');

Problem

I am using `dir` function to list the content of a folder but it gives `.` and `..` for first two folder. Is there any way to get rod of this silly process. Can I use regular expression in `dir` function ? (if I can, it can be a solution)

Original source