Plot a Histogram of the Amplitudes of various frequencies of a Signal

21 ビュー (過去 30 日間)
Riyasat
Riyasat 2015 年 11 月 15 日
コメント済み: Adam Danz 2021 年 8 月 18 日
Hello, I need to plot a bar Histogram of a signal after performing a fft. It is an ENF data, so most amplitudes should be around 60Hz region and around within +/-0.5 Hz. I want an output like the figure I attached. The signal 'x' has length L=10000
code:
x = x(1:1000,1);
T = 1/fs;
L=length(x);
t = (0:L-1)*T;
Y = fft(x);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
I tried using the code
figure(2)
hist(P1,f);
But it doesn't work as I expect. Please help out. thanks.
  4 件のコメント
Yazan
Yazan 2021 年 8 月 18 日
Can you provide the data?
Adam Danz
Adam Danz 2021 年 8 月 18 日
See histfit.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by