You can accomplish this by using the dir() function to read all audio files within the folder, followed by a for loop to assign each audio file to a variable sequentially. Here's an example code snippet assuming all audio files are in the current working directory:
main.m297 chars8 lines
In this code snippet, we first specify the folder directory where the audio files are stored. Then, we use the dir() function to read all audio files within the folder with the extension *.wav.
Next, we use a for loop to iterate over each audio file in files. Within the loop, we construct a full file path using fullfile() and read the audio file using audioread(). We then assign the audio file data to a variable audio_data using the loop index i.
Once the for loop completes, audio_data will contain a sequentially-ordered array of audio file data, where audio_data{1} corresponds to the first audio file in files, audio_data{2} corresponds to the second audio file, and so on.
gistlibby LogSnag