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

조회 수: 3 (최근 30일)
david
david 2015년 2월 1일
답변: Image Analyst 2015년 2월 1일
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