error using wavread

5 views (last 30 days)
Bushra
Bushra on 31 Dec 2011
Hi everyone I am trying to read .wav files in a loop. names of wav files are written in .txt file. The problem is that when i run my code it sometimes works fine but sometimes it give error
??? Error using ==> wavread at 67 Cannot open file.
Error in ==> Main at 9 [y,fs1] = wavread(name);
I have tried everything but cant figure out the problem. I have checked all wav files manually by using same function i.e. wavread on command window, it runs fine there. but same time it dont ru in my code. remember, it generates the error after reading quite a few files. here's my code:
Mul13=[];
fs=16000;
input_code = textread('WordsN.txt','%s','whitespace',' \t\n\r');
len = length(input_code);
for lenth=1:len
name = char(input_code(lenth));
[y,fs1] = wavread(name);
c = melcepst(y,fs);
[c,g,j,gg] = kmeans(c,10);
c=c(:);
Mul13 = [Mul13 c];
end
can anyone help me??? need it urgently :(

Answers (1)

Walter Roberson
Walter Roberson on 31 Dec 2011
There has been evidence that some of the MATLAB file-handling routines do not always close their files, and so when you read enough files you can run out of available file slots.
Some people have suggested that executing fclose('all') from time to time might help. This is not certain.

Community Treasure Hunt

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

Start Hunting!