Question

I have a folder with a set of around 500 WAV files as part of a database.

Now, I would like to traverse the folder contents one by one and apply FFT to each file in MATLAB.

Here is my code so far:

Files=dir('Path\to\file\*.wav');
for k=1:length(Files)
   FileNames = System.IO.Path.GetFullPath(Files(k).name)
   y = abs(fft(wavread(FileNames)))
end

This however gives me no value in y. Is there somewhere I am going wrong with this?

Just to mention, I am getting the full pathnames for each file, but passing that into the FFT function is giving me no result.

Was it helpful?

Solution

The System.IO.Path.GetFullPath give to you the current path from matlab, so Files(k).name can be concatenated in the wrong place.

One way to do:

local='C:\Users\Eder\Downloads\';
filetype='*.wav';
pathsearch = [local filetype];
Files=dir(pathsearch);
for k=1:length(Files)
   FileNames = [local Files(k).name]
   y = abs(fft(wavread(FileNames)))
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top