Loading a file with unknown string name but known structure of the string name

3 views (last 30 days)
Hi,
I'm trying to load files that contains data of experiments (so let's say hundreds or thousands of files). I don't know the name of the files but I know the structure for example:
Name of the file: aa_bbbb_qqq_wwww
where:
"aa" is an integer number
"bbbb" is the name of the device under test
"qqq" is another number (that describes the experimental setup)
"wwww" is the name of the instrument used to performe the measure.
What is the "load" command (if there is any) to read files in such cases?
Thanks in advance for any hint.

Answers (1)

Image Analyst
Image Analyst on 1 Feb 2015
baseFileName = sprintf(%d_%s_%d_%s.dat', int1, str1, int2, str2);
folder = 'c:\mydata'; % Whatever...
fullFileName = fullfile(folder, baseFileName);
mydata = MyReadingFunction(fullFileName);
Write MyReadingFunction() to read whatever kind of data it is, for example it might contain load(), imread(), readtable(), xlsread() or whatever, depending on what kind of format your data is stored in. Then put that snippet into a loop over all files like you'll find in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!