Converting from frequency bins to HZ

Hi everyone, I have a frequency vector with range 0:fs/N:fs/2, is this already in Hz or do I still need to multiply it by fs/N. Also I have a plot of the PSD of an EEG signal. I want the y-axis to be in dB/Hz. How do I do this.

댓글 수: 4

MeitiLuk
MeitiLuk 2020년 11월 12일
can u maybe show your code?
Walter Roberson
Walter Roberson 2020년 11월 12일
That vector is already in Hz.
This is the code
load Subject00_before_fp1.mat;
Sub0 = Subject00_before_fp1(1:5000);
N = length(Sub0);
fs = 500;
t = (1:N)/fs;
subplot(2,1,1);
plot(t,Sub0);
nw = 50;
fp = 0.1;
fst = 25;
wp = fp/fs/2;
ws = fst/fs/2;
wn = [wp,ws];
window = kaiser(nw+1);
b = fir1(nw,wn,'bandpass',window);
y = filter(b,1,Sub0);
subplot(2,1,2);
plot(t,y,'k');
figure;
P = nextpow2(N);
n = 2^P;
X = fft(y,n);
X = X(1:N/2+1);
Pxx = (1/(fs*N)) * abs(X).^2;
Pxx(2:end-1) = 2*Pxx(2:end-1);
f = (0:fs/N:fs/2)*fs/N;
plot(f,10*log10(Pxx));
Ayush Bansal
Ayush Bansal 2020년 11월 18일
The vector is alreay in Hz. 0:fs/N:fs/2 will create a vector from 0 to fs/2 with increment of fs/N Hz. Use pwelch(x) for PSD of a signal.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 EEG/MEG/ECoG에 대해 자세히 알아보기

질문:

2020년 11월 12일

댓글:

2020년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by