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

3 次查看(过去 30 天)
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.

回答(1 个)

Image Analyst
Image Analyst 2015-2-1
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

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by