How can I loop over the files with a particular pattern of filename in the current directory in Octave?
I found glob to be the best option to get a list of files in the current directory and you can use a 'pattern' to get a list of files of a particular pattern. Now I have a list of files which varies over two single integers in the name, such as
A-B123-1-c1, A-B123-1-c2, A-B123-2-c1, A-B123-2-c2.... and so on.
Now I want to loop over the digit between hyphens. I can use the loop variable in the pattern because the digit is sequential, but I can't figure out how to use the variable value within the pattern in glob.
I have used the following code to import filenames with a particular pattern:
filenames = glob("A-B123-*")
However, this code imports all the file names with the pattern A-B123- at once. I am trying to use the following loop:
for j = 1:8
filenames = glob("A-B123-%j-*")
But it outputs an empty cell:
filenames = {}(0x0)
I want the following output when the value of j is 1:
filenames =
[1,1] = A-B123-1-c1
[2,1] = A-B123-1-c2
Can anyone suggest a solution?