필터 지우기
필터 지우기

How to make a for loop for fft?

조회 수: 5 (최근 30일)
Sag
Sag 2016년 2월 16일
댓글: Sag 2016년 2월 16일
Cell Final is (1x15) and it has vectors each 1x2545. I want to run fft function for each vector of cell Final using a for loop. Ultimately I have to compare data from all the 15 row vectors. Here what I have tried:
Final=1x15 cell and each element is a 1x2545 vector
Fs = 1.0173e+03; % Sampling frequency
L = 2500; % Length of signal
NFFT = 2^nextpow2(L);
f=Fs/2*linspace(0,1,NFFT/2+1);
for yy=1:length(Final);
YY= fft(Final(1),NFFT)/L;
YY(1)=[];
power=(2*abs(YY(1:NFFT/2+1)));
plot(f,power);
end

채택된 답변

Geoff Hayes
Geoff Hayes 2016년 2월 16일
Sag - if Final is a cell array, then your for loop would look something like
for k = 1:length(Final)
YY = fft(Final{k},NFFT)/L;
% etc.
end
Note how we use the indexing variable k to access the kth cell element of Final using the braces {}.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by