Hello there,
I am wondering if there is some matlab user who can help me out a little. Am new to matlab
I am working on a matlab project that requires the use of wavread() function to read .wav files and analyze them.
my matlab function is constructed:
- Accept three input parameters
- construct a filename from this
- pick this file from a directory
- read the contents of the file into a variable using wavread()
- compute average, mean, and variance from the data extracted from the files
see my function code
***********************************************************************************************
function [meanFreq,varFreq] = INTRA_SAMPLE_FREQUENCY_VARIANCE(subjectno,sampleCount,dataset)
%declare local variables
totalFreq = 0;
varFreq=0;
meanFreq=0;
sample=0;
c = 0;
for n=1:sampleCount
filepath = sprintf('%s_%d_%s',subjectno,n,dataset);
[sample,fs]= wavread(filepath);
maxFreq = max(abs(fft(sample)));
totalFreq = totalFreq + maxFreq;
c=c+1;
if isequal(n,sampleCount)
break;
end;
meanFreq = totalFreq/c
varFreq = varFreq + (maxFreq - meanFreq)^2
disp('------------------------------------------------------------------')
end;
**************************************************************************************************
My problems are
- when i run this code, it outputs correct values (for sample, maxFreq,totalFreq which means it extracted from the .wav file) however, at the end of the results it reports ??? Error using ==> wavread!!!
- Secondly, i only need the function to print/return the meanFreq, and varFreq values. When i move the code computing these values outside of the for loop, it fails to return any value at all!
I have been on it for the better part of 2 days. ANY HELP WOULD BE APPRECIATED!!!