How can I plot FFT (Fast Fourier Transform) in a for loop?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!