MATLAB: Dir command addresses one extra file

dir

Hello all,
I have a folder containing 9 .htk files. I need to use "dir", and then "readhtk" in a loop to import them to MATLAB, but DIR appears to give 10 files instead of 9! here is my code:
htkfiles = dir('/Users/Desktop/Acsegment/mfcdir/*.htk');
nhtkfiles = length(htkfiles); % 10!!! It should be 9 tough!
data = cell(nhtkfiles,2);
for k = 1:nhtkfiles
b(k,1) = strcat({'/Users/Desktop/Acsegment/mfcdir/'},{htkfiles(k,1).name});
eval(['data{k,1} = readhtk(b{k,1});']);
end
When looking at the filenames in htkfiles, I have them like this:
htkfiles(1,1).name = '.htk'
htkfiles(2,1).name = 'fadg0_si1279.htk'
htkfiles(3,1).name = 'fadg0_si1909.htk'
htkfiles(4,1).name = 'fadg0_si649.htk'
htkfiles(5,1).name = 'fadg0_sx109.htk'
htkfiles(6,1).name = 'fadg0_sx19.htk'
htkfiles(7,1).name = 'fadg0_sx199.htk'
htkfiles(8,1).name = 'fadg0_sx289.htk'
htkfiles(9,1).name = 'fadg0_sx379.htk'
htkfiles(10,1).name = 'faks0_si943.htk'
Comparing to what I see in that folder, the first file is not supposed to be there! Anyone got any ideas why Im getting one extra file?

Best Answer

If all you want to do is remove files starting with '.', it's simply
htkfiles = dir('/Users/Desktop/Acsegment/mfcdir/*.htk');
htkfiles(strncmp({htkfiles.name}, '.', 1)) = []; %remove files and dir starting with '.'
Or, to remove directory as well (a good idea):
htkfiles(strncmp({htkfiles.name}, '.', 1) | [htkfiles.isdir]) = []; %remove directory from list as well
As per my comment, you can then continue with:
htkfullpath = strcat('/Users/Desktop/Acsegment/mfcdir/', {htkfiles.name});
data = cellfun(@readghtk, htkfullpath, 'UniformOutput', false);