Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Jose Peñaloza
Jose Peñaloza le 13 Août 2015
Modifié(e) : Jose Peñaloza le 13 Août 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

Réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by