How can I plot FFT (Fast Fourier Transform) in a for loop?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!