how do i sequentially read audio and sequentially name the audioread data as variables in matlab

You can use a for loop to sequentially read audio files in MATLAB and name them as variables. Here's an example code:

main.m
% Set the path to the folder containing audio files
audio_folder = 'path/to/audio/files/';

% Get the list of audio files in the folder
audio_files = dir(fullfile(audio_folder, '*.wav'));

% Loop through each audio file
for i = 1:length(audio_files)
    
    % Construct the full file path
    file_path = fullfile(audio_folder, audio_files(i).name);
    
    % Read the audio data using audioread
    audio_data = audioread(file_path);
    
    % Name the audio data as a variable (you can modify this as per your needs)
    eval(['y' num2str(i) ' = audio_data;']);
    
end
576 chars
20 lines

This code reads all the WAV files in a folder one-by-one, and names the audio data as variables y1, y2, and so on, sequentially. You can modify the naming convention to suit your use case.

related categories

gistlibby LogSnag