"Unrecognized function or variable 'filename'. Error in audioread (line 82) filename = convertStringsToChars(filename);'
Show older comments
I am building the MIT Radar course, where you can download the doppler files. With the Doppler Files is a .wav file. I typed in
[Y, FS]= audioread('Off of Newton Exit 17.wav');
because this contains both variable values. I ran this last night and it worked. But I woke up this morning to run it again and it keeps giving me this 'Unrecognized function or variable 'filename' error. I tried using convertStringsToChars('Off of Newton Exit 17.wav') which it goes through, but it doesn't pull the variables like I need it to. it returns to the same error. I have tried changing the location, I have taken the entire address out of the audioread. Nothing has worked yet.
I looked up the error advising that the parsen is <0... I am absolutely stuck. Any help would be great. Thank you

1 Comment
Yongjian Feng
on 24 Jul 2021
Is this file somewhere in your hard drive?
Answers (2)
Your variable "info" is a struct, not a char vector or string.
info = audioinfo('Off of Newton Exit 17.wav');
[Y, FS] = audioread(info.Filename);
Under Matlab R2018b your code fails also, but with a different error message.
8 Comments
Marsha Groen
on 24 Jul 2021
% Your code:
[Y, FS] = audioread(info.Off of Newton Exit 17.wav);
% My code:
info = audioinfo('Off of Newton Exit 17.wav');
[Y, FS] = audioread(info.Filename);
Please try my suggestion and not something, which looks a little bit similar.
I do not understand, what this means: "Now I tried this is MATLAB 2020 and it pulled it with no error, until further into the code where the matrix was matching, and because its outdated it won't let me redirect the harddrive path".
Marsha Groen
on 25 Jul 2021
Walter Roberson
on 25 Jul 2021
Please show us the output of
dbtype fileread 1
Also, notice that you have a blank between .wav the the closing quote that should probably not be there.
Marsha Groen
on 25 Jul 2021
Marsha Groen
on 25 Jul 2021
Jan
on 25 Jul 2021
@Walter Roberson: Do you mean:
dbtype audioread 1 % not fileread
@Marsha Groen: Please post code as text and not as screen shots.
I asked you to copy my code carfully.
% My code:
info = audioinfo('Off of Newton Exit 17.wav');
% Your code
info = audioinfo('Off of Newton Exit 17.wav ');
% ^ additional space
Your code should fail with the error message:
% Error using audioinfo (line 51)
% The filename specified was not found in the MATLAB path.
Trailing spaces are not allowed for file names under Windows.
You have tried a lot of versions, which contain a variety of typos:
[data, FS] = audioinfo('Off of Newton Exit 17.wav');
[data, FS] = audioread('info');
[data, FS] = audioinfo(info;
[data, FS] = audioinfo(info);
[Y, FS] = audioread(info.Off of Newton Exit 17.wav);
info = audioinfo('Off of Newton Exit 17.wav ');
function [y,Fs] = audioread('Off of Newton Exit 17.wav', double);
[Y, FS] = audioread;
Programming languages are very susceptible for inserting some characters at the wrong locations. You have to crae for writing exactly want is needed. There is not fuzzy logic, which tries to fix such typos automagically.
A very bold guess:
Are you working with admin privileges? Did you open the file audioread.m and overwrite the first line of code, which should be
function [y,Fs] = audioread(filename, range, datatype)
How does the function start on your computer?
edit audioread
8 Comments
Marsha Groen
on 25 Jul 2021
Marsha Groen
on 25 Jul 2021
Sorry, Marsha, the discussion is becoming weird.
I do not have a chance to know, if your local account has admin privileges or not. It is your turn to find this out. Ask your IT-admin on demand. If you do have admin privileges, you can destroy Matlab's built-in functions by editing them by accident. Therefore this is a really bad idea.
function [y,Fs] = audioread('Off of Newton Exit 17.wav', double);
% ^^^^^^ ?!?
I'd never told you to create a function called "audioread". But if you have done this before, it would explain, why your audioread function is crashing. In addition the trailing "double" is completely orphaned. This is not valid Matlab syntax. This kind of shotgun programming cannot produce running code.
[Y, FS] = audioread;
How should this work, if you do not provide a file name.
The working code is (as posted above):
info = audioinfo('Off of Newton Exit 17.wav');
[Y, FS] = audioread(info.Filename);
If this is failing, the file audioread.m contains a bug. The original version of this function is running, so this means that you call a modified version. This means, that modifying the original function was the problem. You have to fix this. Varying the commands to call this function will not help, most of all if you try it with wild guessing.
Start with checking, if there are multiple, maybe user-defined, files for the function audioread in your path:
which audioread -all
What do you get as answer?
Marsha Groen
on 25 Jul 2021
Image Analyst
on 25 Jul 2021
Looks like you have your own custom version of audioread() that you wrote. It's not a good idea to name your own variables or functions after built-in variables or functions in MATLAB. Rename your audioread.m to something else.
Jan
on 25 Jul 2021
As Image Analyst has explained, your code calls the file:
C:\Users\Sissy\MATLAB Drive\doppler_files(1)\doppler_files\audioread.m
for the command audioread. Obviously this file has been damaged. Rename it, or if you do not need it, delete it.
Marsha Groen
on 25 Jul 2021
Jan
on 26 Jul 2021
You are welcome. Matlab problems are the purpose of this forum. The harder the problem, the more useful is the help. :-)
Categories
Find more on Univariate Discrete Distributions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!