MATLAB: How to run a batch of pairs of files

filesfolders

I have what I assume is a dumb question, yet I cannot find an answer to it. I want to write a programme to run a bunch of tests through a function and store the answers produced. Each run of the function requires two files, and each file has a pair with which it must be run. Something like: runfile('1a.txt', '2a.txt'); where 1a.txt and 2a.txt are a pair of files. How could I get a program to run each pair of files? I assume I should first separate the two types of files into separate folders. Once I do that, and they are in the same order in each folder (ie. file 1a is the first file in folder 1, and file 2a is the first in folder 2 etc.), what should I use to get the files from the folders and run them through the function?

Best Answer

Files do not have an order in folders. Although DIR replies the files in alphabetically sorted order, this is not guaranteed.
[EDITED] You have explained the rule. Then: [EDITED 2] Considering your comments:
function runbatch(sml_folder, iml_folder)
smlDir = dir(fullfile(sml_folder, '*.sml'));
smlFile = {smlDir.name};
for iFile = 1:length(smlFile)
aFile = smlFile{iFile};
aName = fileparts(aFile);
aSMLFile = fullfile(sml_folder, aFile);
aIMLFile = fullfile(iml_folder, [aName, '.iml']);
runfile(aSMLFile, aIMLFile);
end