How to open a .wav file from matlab using a string name?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
... and thanks for helping.
I want to open a .wav file in matlab just from a string name. I don't know what the string name will be until I run the program. I do know that whatever the string name will be, it will exist in the current folder.I have tried multiple approaches unsuccessfully. below is the latest that I have produced
if true
list=get(handles.targetSelection_popupmenu,'String');
val=get(handles.targetSelection_popupmenu,'Value');
str=list{val};
filename=[sr,'.wav'];
[VoiceTrgt fsTrgt]=wavread(filename,'.wav');
end
It does not work. so, as you can guess, str can be, say, Symphony11 or Symphony12 or whatever... I want to read the Symphony.
Thanks.
0 个评论
回答(1 个)
Wayne King
2013-3-31
编辑:Wayne King
2013-3-31
Can you say what error you are getting? I'm not sure why you have the following
filename=[sr,'.wav'];
[VoiceTrgt fsTrgt]=wavread(filename,'.wav');
Why are you calling wavread with an '.wav' input argument? There is no such input argument. The above is probably giving you an "unrecognized data format" error because it expects a string like 'double' or 'native'
Just do the following
filename = [sr, '.wav'];
[VoiceTrgt fsTrgt]=wavread(filename);
Assuming that filename ends up as something like symphony11.wav.
By the way, the recommend functionality to use is audioread() assuming you have a version of MATLAB that contains that function.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!