how do i read multiple audio file from different files name ?
이전 댓글 표시
i have a folder about 136 subfolders which have different names
f1
f2
.
.
.
.
f136
and each subfolder has 10 audio file
these audio files have the same name for whole subfolders
f1 [ sa1 sa2 ....... sa10]
f2 [sa1 sa2 .... sa10]
.
.
f136 [sa1 sa2 ... sa10]
so i need to read them in one matrix
can anyone help me
i will be appreciate
댓글 수: 1
Stephen23
2020년 12월 23일
"so i need to read them in one matrix"
Does your computer have enough memory to store all of the imported data in one array? Or for that matter, in separate arrays?
채택된 답변
추가 답변 (2개)
weikang zhao
2020년 12월 23일
You need a loop body, the loop body continuously generates the path of the audio file.
Run the following script and you will understand.
for i=1:136
for j=1:10
filename=['f',num2str(i),'\sa',num2str(j),'.wav'];
disp(str);
%code to read the audio file %
end
end
have fun!
댓글 수: 4
Stephen23
2020년 12월 23일
Where is str defined?
weikang zhao
2020년 12월 23일
sorry
disp(filename);
rusul a
2020년 12월 23일
weikang zhao
2020년 12월 23일
you can get all the names of the subfolder by "dir" function, for example
X=dir;
X will contain information about all subfolders and files in the current folder, X is a struct array, and you can traverse the 'name' field of X.

jibrahim
2020년 12월 23일
If you have access to Audio Toolbox, there is no need for much custom code to accomplish this. Just use audioDatastore.
From the top folder:
ads = audioDatastore(pwd,'IncludeSubfolders',true);
data = readall(ads);
data is a cell array with the audio from all files. If all entries in data have the same dimensions, you can concatenate the signals in a matrix.
카테고리
도움말 센터 및 File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!