MATLAB: Read .csv files in the right order

csv

Hello, i have a lot of .csv files do read (around 1500) and need to get a value from each. The problem is that the files appear out of the right order. My code:
list = dir('directory.csv');
numFiles = length(list);
for iFile = 1:numFiles
FileName =list(iFile).name;
Data(iFile).FileName = FileName;
end
for i=1:numFiles
A =dlmread(Data(i).FileName,',',[4 1 4 6]); B(i)=A(1,3);
end
plot(B)
The list structure fills as appear in the picture in attachment.
How can i order the right way?

Best Answer

The simplest solution is to download my FEX submission natsortfiles and use it like this:
D = 'C:\directory';
S = dir(fullfile(D,'*.csv'));
N = natsortfiles({S.name});
for k = 1:numel(N)
filename = fullfile(D,N{k})
end