1
我想從某個目錄讀取幾個文件。這裏是我的腳本:讀取多個文件(wavread)
prefix = '\wav\';
wav_arr = ['1.wav'; '2.wav'; '3.wav'];
wav_arr = cellstr(wav_arr);
len = length(wav_arr);
sig = [];
fs = [];
for i = 1:len
path = strcat(pwd, prefix, wav_arr(i));
[s, curr_fs] = audioread(path);
sig = [sig s];
fs = [fs curr_fs];
end
但我收到的錯誤:
Error using which
Argument must contain a string.
Error in audiovideo.internal.absolutePathForReading (line 7)
whichFileName = which(filename);
Error in audioread (line 74)
filename = audiovideo.internal.absolutePathForReading(...
Error in main_experiment (line 14)
[s, curr_fs] = audioread(path);
的問題是,path
是1x1 cell
,它不是一個string
。對於path
執行cellstr()
不起作用。
路徑是MATLAB函數避免使用這個名字作爲變量! – obchardon