Borrar filtros
Borrar filtros

How can I plot FFT (Fast Fourier Transform) in a for loop?

2 visualizaciones (últimos 30 días)
Jose Peñaloza
Jose Peñaloza el 13 de Ag. de 2015
Editada: Jose Peñaloza el 13 de Ag. de 2015
I have this code, it works until m=numfiles, the last part is a code I used for FFT only for one file but I want to adapt in a for-end loop. Data is in cells. I tried to adapt but it doesn't work.
files= dir('*.avi');
numfiles=length(files);
mydata= cell(numfiles,1);
info=cell(numfiles,1);
isFileSupported = true(numfiles, 1) ;
for j=1:numfiles
try
info{j}=mmfileinfo(files(j).name);
audio = info{j}.Audio
video = info{j}.Video
catch ME
isFileSupported(j) = false;
continue;
end
end
supportedFiles = files(isFileSupported);
for k=1:numel(supportedFiles)
mydata{k}=importdata(supportedFiles(k).name);
end
if true
% code
end
m=numfiles
nfft=2^nextpow2(m);
Numnfft=length(nfft);
x_HannWind=x.*hanning(m);
Y=fft(x_HandWind,nfft)/m; %Fast Fourier Transform%
length(Y);
Y_mag = abs(Y); %Magnitude FFT%
plot(Y_mag);
xlabel('Frecuence [Hz]')
ylabel('Magnitude')
end

Respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by