How do I load multiple files that have a certain word in the filename?

2 views (last 30 days)
So I'm loading multiple files from a folder and I've managed to limit the files to a specific filetype, such as dat files. However, the files have different names and may include words like "uni" or "bi" or "tri" in the title. Is there a way for me to load only files that have that word in the title? This is what I have so far.
directory_name = uigetdir;
files = dir(fullfile(directory_name, '*.dat'));
fileName={files.name};

Answers (1)

Image Analyst
Image Analyst on 10 Nov 2012
Have a loop over the files, adding the name to a cell if the name contains the letters you want. You can use strfind() for that.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!