MATLAB: Importdata: file name string operations

data importmultiple filesstrings

Hi,
My program simulates some physical stuff and I store my results in different files, which I index according to my liking. To gather more data I add another index to the file name, so that I can run the program on different computers and then collect all the data files without having to overwrite those that have the same (first) index. The whole thing eventually looks like this: ['file_name_primary_index' 'secondary_index']
This is the easy part. Now I have to access the files with the same primary index. I know the 1st part of the file name (which is 'file_name_primary_index'). The 2nd part doesn't interest me, because it could be anything, technically, so this one is unknown. But the importdata function requires the FULL name of the file.
The best way to do this is to shove the result of "dir file_name_primary_index" in a vector, so that I could get all names containing that string. Theoretically of course. Now I don't know how to do that. (A=dir is an option, but then, how do I pull off the unnecessary files?)
Thnx!

Best Answer

a = dir('file_name_primary_index*'); %use wildcard