在matlab中读取多个wav文件 [英] read multiple wav files in matlab
问题描述
我想一对一地读取多个wav文件.我这样写,但是它给出了无效的Wave文件.原因:无法打开文件."错误.但是,当我将t更改为数字时,它可以工作.
I want read multiple wav files one by one in one folder. I wrote this way, but it gives "Invalid Wave File. Reason: Cannot open file." error. But when i change t to number, it works.
for t=1:10
myFile=['path\','t.wav'];
[ speech, fs] = wavread( myFile);
end
推荐答案
您需要将变量t
转换为字符串.您正在要求打开文件'path\t.wav'
,该文件可能不存在.由于变量t
是整数,因此可以使用 int2str
将其转换为字符串:
You need to convert the variable t
to a string. You were asking to open the file 'path\t.wav'
, which presumably doesn't exist. Since the variable t
is an integer, you can use int2str
to convert it to a string:
myFile = ['path\' int2str(t) '.wav'];
仅字符串可以与其他字符串串联.当然,如果文件少于10个,那么您将遇到另一个问题...
Only strings can be concatenated with other strings. Of course if you have fewer than 10 files, then you'll have another problem...
这篇关于在matlab中读取多个wav文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!