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.

Était-ce utile?

La 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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top