Error using a variable as input for audioread()
4 次查看(过去 30 天)
显示 更早的评论
Hello.
I'm trying to load a .wav file, based on user input. For testing, I am using sample.wav. When I type audioread('sample.wav'), it works perfectly, but when I type:
fileName1 = inputdlg('Type the filename of the .wav file you would like to upload');
% A dialogue box pops up and I type sample.wav into it
audioread(fileName1);
This results in the following error:
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(...
What am I doing wrong?
4 个评论
Saad Rehman
2020-4-17
Undefined variable "audiovideo" or class "audiovideo.internal.absolutePathForReading".
Error in audioread (line 74)
filename = audiovideo.internal.absolutePathForReading(...
I've an error. kindly guide me how can I solve it?
Geoff Hayes
2020-4-17
Saad - what is the line of code that you have written to load your audio file? Are you using audioread?
回答(1 个)
Harsha KVK
2022-7-28
As input() takes only integers. Convert the file name to string.
fileName = string(input('Type the filename of the .wav file you would like to upload')); audioread(fileName);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!