Q:

octave function wavread cannot open wav file

I am attempting to use octave to read a .wav file into a vector array for other analysis, but when I try to run the script, octave cannot open the file.
The code is:
[S,fs] = wavread('snare.wav');
plot(S);

Upon running the script, I get the following error:
error: audioinfo: failed to open file snare.wav
wavread at line 91 column 8
analysis_1 at line 1 column 7

I have the 'snare.wav' file in the same directory as the script file 'analysis_1.m', so the compiler should be able to find the .wav file. It is just that octave cannot open the file. 
I am running ubuntu on a Dell XPS.
Any help would be appreciated. Should I try to reinstall octave? 
Thanks community

A:

It doesn't matter if the file snare.wav is in the same directory as the file analysis_1.m. The importand point is, that the wave file is in the "current directory" when waveread is called with 'snare.wav'. This is important if you change directories with cd in your script or you call scripts and functions with realtiive paths or add them via addpath. I'll show you the last one as example.
Consider following structure:
.
└── foo
    ├── bar.m
    └── myfile

the file bar.m only consists of stat myfile
If you now navigate to foo with cd and call bar you get as result
octave:1> bar
ans =

  scalar structure containing the fields:

    dev =  2065
    ino =  5672946
    mode =  33188
    modestr = -rw-r--r-- 
    nlink =  1
    uid =  1000
    gid =  1000
    rdev = 0
    size =  6
    atime =    1.5196e+09
    mtime =    1.5196e+09
    ctime =    1.5196e+09
    blksize = 0
    blocks =  8

But if you, for example use addpath and you are outside foo:
octave:1> addpath ("foo")
octave:2> bar
ans = [](0x0)

the file isn't found.
So to debug your code, just add pwd and ls directly before your waveread
and check if they met your expectation or add a keyboard and debug from this

