# Choosing one peak out of two in FFT function

조회 수: 1(최근 30일)
Hussein Kokash 2022년 10월 5일
댓글: William Rose 2022년 10월 6일
Hello,
I have a question about how to choose only one out the two peaks that are produced after applying FFT function.
I have multiple text files where each one has "y" values, each file is at a certain time step so the peak of the FFT function is different for every file. Each one produces two peaks the same way in the image, is there a way to take just one of the highest two peaks for each file and store them to either plot or post process.
I tried findpeaks, but the problem is since it is varying peaks, it is difficult to set a parameter such as 'MinPeakDistance' or other.
I use the following:
A = fft(y);
B = abs(A);
figure()
hold on
semilogy(B)
hold off
even if I use C = max(abs(fft(y))); it would not decide which max to choose
Note: the first image is for one file, the second image is for multiple files
Thank you!

댓글을 달려면 로그인하십시오.

### 채택된 답변

William Rose 2022년 10월 5일
The output of y=fft(x) is symmetric about the middle of the array y.* This is due to the mathematics of the discrete Fourier transform. So when identifying peaks, you can ignore those that occur above element N/2, where N is the length of x and of y.
*When the input sequence,x, is real numbers.
##### 댓글 수: 7표시 이전 댓글 수: 6숨기기 이전 댓글 수: 6
William Rose 2022년 10월 6일
You're welcome.
You have an interesting problem and an interesting experiment.
The code I provided gives f1, the frequency with the most power in the signal. Obviously the associated wavelength is lambda1=c/f1. The frequencies of the peaks in the "top half" of the spectrum (the part above the Nyquist frequency) have no additional value for your analysis.

댓글을 달려면 로그인하십시오.

### 범주

Find more on Descriptive Statistics in Help Center and File Exchange

R2018a

### Community Treasure Hunt

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

Start Hunting!

Translated by