I have a directory that has about 1000 images. In my matlab code, I have to process these images in order by names.( img1.jpg , img2.jpg and so on). Is there a way to read from the images directrory in order so img1.jpg will be processed, then img2.jpg and so on? Thank you in advance.

```
imgFilesDir =dir('pics/*.jpg');

for n=1:length(imgFilesDir)
%read Target image and convert into single
   rgb2= im2single(imread(strcat('pics/',imgFilesDir(n).name)));
   I2 = rgb2gray(rgb2);
end

```