Plot fft and peaks on same plot
조회 수: 16 (최근 30일)
이전 댓글 표시
Hey guys, I am having trying to plot the fft and its peaks on the same plot. I have read that passing the frequency vector in findpeaks will allow the second argument to be in frequency so i have done that in the code i provided below on line 13. However, I am having a hard time plotting the peaks and the fft on the same plot. If someone could point out how to plot this that would be appreciated. Thank you.
댓글 수: 0
채택된 답변
Star Strider
2020년 8월 5일
You did not provide ‘x’ or any of the parameters (such as ‘Fs’) so it is not possible to run your code, and you could easily have posted your code as an attachment here instead of pastebin.
That aside, try this:
[pks,locs] = findpeaks(20*log10(abs(xdft));
figure(2)
semilogx(freq,20*log10(abs(xdft)))
hold on
plot(freq(locs), pks, 'or')
hold off
xlabel('f(Hz)');
title('FFT of signal')
It is necessary to use the same values in the plot as in the findpeaks arguments.
.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!