How can I plot FFT (Fast Fourier Transform) in a for loop?
1 回表示 (過去 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!