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];

Answers (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

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Release

R2021a

Asked:

on 27 Jun 2021

Answered:

on 28 Jun 2021

Community Treasure Hunt

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

Start Hunting!