hello, I have a plot of values from my fft function for a sinewave audio signal. I am now trying to analyze each peak in the plot to give me the sum of the peak and two other lower points on both sides of the peak. can anyone please help?

댓글 수: 1

God'sSon
God'sSon 2011년 5월 23일
Hello,
This is the program I am trying to explain. After this is executed, how can I use the program to get the values of the peaks in the plot into my program?
N=2048;
fs=48000;
n=0:1:N-1;
F = fs*[0:N-1]/N;
w_a=sin((pi*(n'+0.5))/N);% calculate sine window
x1=w_a'.*sin(n*pi/24);
X1 = abs(fft(x1,N)).^2;
plot(F,X1)

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

 채택된 답변

Laura Proctor
Laura Proctor 2011년 5월 23일

0 개 추천

[Xm Im] = findpeaks(X1)
Fm = F(Im)
The Fm and Xm values will hold your x and y values for the peaks.

댓글 수: 5

God'sSon
God'sSon 2011년 5월 24일
thank you for your answer. but how do I find at least two other points on either side of each peak.
Laura Proctor
Laura Proctor 2011년 5월 24일
Im holds the index values, so to get the points on either side of the peaks, just use Im - 1 and Im + 1.
God'sSon
God'sSon 2011년 5월 24일
do you mean [Xm Im-1] = findpeaks(X1)
[Xm Im+1] = findpeaks(X1)?
Laura Proctor
Laura Proctor 2011년 5월 24일
Not quite...
[Xm Im] = findpeaks(X1)
iVals = reshape([ Im - 1 ; Im ; Im + 1],1,[])
xVals = F(iVals)
yVals = X1(iVals)
God'sSon
God'sSon 2011년 5월 24일
this works perfectly. thank you very much.

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

추가 답변 (0개)

카테고리

태그

Community Treasure Hunt

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

Start Hunting!

Translated by