
data_structure 是(长度(Num_sounds)行x3列单元格的单元格。
for i=1:num_sounds; cd(char(sound_dirs{i})); %open a directory wav_list=dir('*.wav'); %get all the .wav files in the folder data_structure{i,2}=wav_list; % fills second column with struct the length of the .wav files. data_structure{i,1}=words{i}; end问题在这里
for i=1:num_sounds;
num_wavs=length(data_structure{i,2});
for i=1:num_wavs;
[y Fs]= audioread((data_structure{i,2}.name)); %%problem here我意识到问题是,我在同一时间调用同一个文件夹中的所有'.wav‘文件,而不是每次都接收
我试过data_structure{1,2}.name(40); % the first folder has 47 .wav files
但那不管用。
name <--保存.wav文件的所有名称。

发布于 2019-04-14 05:20:16
排在队伍里
[y Fs] = audioread((data_structure{i,2}.name)); %%problem here表达式data_structure{i,2}.name将同时将所有文件名(在您的示例中为47个)作为输入参数提供给函数audioread,从而产生错误消息。
如果要单独访问每个.wav文件,则需要在从dir返回的结构中对它们进行索引,即,
for i=1:num_sounds;
these_files = data_structure{i,2};
for i=1:length(these_files)
[y Fs] = audioread(these_files(i).name));
% Do whatever needs to be done with y, Fs
end
endhttps://stackoverflow.com/questions/55671704
复制相似问题