plot specific frequency of signal
조회 수: 1 (최근 30일)
이전 댓글 표시
I would like to plot the 0 to 50 Hz of ecg signal by FFT. How Can I change it that plot the 0 to 50 Hz frequencies.
this is my code
a1 =importdata ('ecg.txt');
Fs = 500; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(a1);
nfft = 2^nextpow2(L);
y=fft(a1,nfft)/L;
y1=abs(y);
f=(0:nfft/2)*Fn*2/nfft;
figure
plot (f,y1(1:numel(f))
title ('‘Frequency Domain’')
xlabel('f(Hz)')
ylabel('|y1(f)|')
grid
댓글 수: 0
답변 (1개)
Star Strider
2023년 3월 8일
편집: Star Strider
2023년 3월 8일
Are you certain that 500 Hz is the correct sampling frequency for this trace?
That would calculate to a heart rate of 335 bpm!
That aside, one way to analyse it —
a1 = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1317805/ecg.txt');
% EKG file found in: I would like to calculate heart rate by determining threshold for amplitude
% https://www.mathworks.com/matlabcentral/answers/1925115-i-would-like-to-calculate-heart-rate-by-determining-threshold-for-amplitude?s_tid=srchtitle
Fs = 500; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(a1);
Duration_sec = L/Fs
R = islocalmax(a1, 'MinProminence',0.75);
HR = nnz(R)/Duration_sec * 60 % BPM
nfft = 2^nextpow2(L);
y=fft((a1-mean(a1)).*hann(L),nfft)/L;
y1=abs(y);
f=(0:nfft/2)*Fn*2/nfft;
figure
plot (f,y1(1:numel(f)))
title ('‘Frequency Domain’')
xlabel('f(Hz)')
ylabel('|y1(f)|')
grid
t = linspace(0, L-1, L)/Fs; % Time Vector
figure
plot(t, a1)
hold on
plot(t(R), a1(R), '^r')
hold off
grid
xlabel('Time (s)')
ylabel('Amplitude (mV)')
figure
plot(t, a1)
grid
xlabel('Time (s)')
ylabel('Amplitude (mV)')
xlim([0 1])
.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 ECG / EKG에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!