How to read multiple wave files into Matlab with "Audioread" processing and plotting

After searching long and hard and not finding anything, I hope someone can help me.
I have several wave files that I want to read in.After that I want to concatenate these wave files,like wagons on a train to plot them together.
The code is working but for not more than 15 files.After the computer freezes.
f_nameV = strcat(date,'*_*_*_*_name.wav'); %concatening pathparts
filePatternV = fullfile(PathV,f_nameV); %creating path
vibra = dir(filePatternV); %listing files into array
% Vy = zeros (52200000,1); % me trying to prealloacte the Variable Vy
Vy = 0;
for l = start_l : end_l % Start_1 = 1 and end _1 = e.g. 15 (maximum of what is possible right now )
baseFileName = vibra(l).name;
fullFileName = fullfile(vibra(l).folder, baseFileName);
fprintf(1, 'loaded file %s\n', fullFileName);
[y,VFs] = audioread(fullFileName);%[y,Fs] = audioread(filename) reads data from the file named filename, and returns sampled data, y, and a sample rate for that data, Fs.
Vy = [Vy ; y];

답변 (1개)

hello
simple demo code :
clearvars
% A simpler, neater, more efficient solution is to use the structure returned by DIR:
% P = 'C:\Users\salonsov\Desktop\Results_lowflows\seasons';
P = cd;
S = dir(fullfile(P, '*.wav'));
Vy = [];
for k = 1:numel(S)
fullFileName = fullfile(P, S(k).name);
[y,VFs] = audioread(fullFileName); %
fprintf(1, 'loaded file %s\n', fullFileName);
Vy = [Vy ; y];
end

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 6월 27일

답변:

2021년 6월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by