"Unrecognized function or variable 'filename'. Error in audioread (line 82) filename = convertStr​ingsToChar​s(filename​);'

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

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

>> [Y, FS] = audioread(info.Off of Newton Exit 17.wav); only comes back as invalid expression even with the quotation marks
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
% 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".
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.
clear all;
close all;
[Y, FS] = audioread('Off of Newton Exit 17.wav');
c = 3E8;
Tp = 0.250;
N = Tp*Y;
fc = 2590E6;
s = -1*Y(:,2);
clear Y;
for ii = 1:round(size(s,1)/N)-1
sif(ii,:) = s(1+(ii-1)*N:ii*N);
end
sif = sif - mean(s);
zpad = 8*N/2;
v = dbv(ifft(sif,zpad,2)); % This is another dbv.m file
%dbv.m is
%function out = dbv(in)
%out = 20 * log10(abs(in));
v = v(:,1:size(v,2)/2);
mmax = max(max(v));
delta_f = linspace(0, data/2, size(v,2));
lambda=c/fc;
velocity = delta_f*lambda/2;
time = linspace(1,Tp*size(v,1),size(v,1));
imagesc(velocity,time,v-mmax,[-35, 0]);
colorbar;
xlim([0 40]);
xlabel('Velocity (m/sec)');
ylabel('time (sec)');
@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.

Sign in to comment.

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

This is where I pull my beginner card... I have no idea. How would I check if I have admin privileges. So what you are saying is to make a seperate .m file... saying:
function [y,Fs] = audioread('Off of Newton Exit 17.wav', double);
Then calling the mfile [Y, FS] = audioread;
Here is my mfile
function [Y,FS] = audioread('C:\Users\Sissy\MATLAB Drive\doppler_files(1)\doppler_files\Off of Newton Exit 17.wav', double);
When I run it...
[Y, FS] = audioread;
File: audioread.m Line: 1 Column: 29 Invalid expression. Check for missing multiplication operator, missing or
unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
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?
No I don't have admin privileges. I can take double out but it is correct as the dataype the day before was double.
which audioread -all
C:\Users\Sissy\MATLAB Drive\doppler_files(1)\doppler_files\audioread.m
E:\MATLAB\toolbox\matlab\audiovideo\audioread.m % Shadowed
C:\Users\Sissy\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\audioread - unified audio file input function\audioread\audioread.m % Shadowed
>>
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.
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.
I had to uninstall the software and reinstall it on the PC instead of my external harddrive. It works now thank goodness. I appreciate all hands that were helping out, thank you for your time.
You are welcome. Matlab problems are the purpose of this forum. The harder the problem, the more useful is the help. :-)

Sign in to comment.

Products

Release

R2021a

Asked:

on 24 Jul 2021

Commented:

Jan
on 26 Jul 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!