How do you repeat a QRS signal?

1 view (last 30 days)
I have a code that currently plots the magnitude and phase components of an ECG signal. Currently I have it plot only one cycle of a wave in Figure 1, but I need it to plot more than one so I can calculate the time duration between the two consecutive R peaks. I also want to see if I can determine the bandwidth of the signal using 'bw = powerbw(x)' command. Finally, is there a way to lanel the frequencies with the largest magnitude?
clear all; close all;
load ECG1;
fs = 125;
N = length(ecg);
t = (1:N)/fs;
plot(t,ecg);
xlabel('Time (sec)');
ylabel('ECG');
figure;
f = (1:N)*fs/N;
N2 = round(N/2);
X = fft(ecg);
Mag = abs(X);
Phase = (unwrap(angle(X)))*360/(2*pi);
subplot(2,1,1);
plot(f(1:N2-1),Mag(2:N2));
xlabel('Frequency (Hz)');
ylabel('|ECG(f)|');
subplot(2,1,2);
plot(f(1:N2-1),Phase(2:N2));
xlabel('Frequency (Hz)');
ylabel('Phase ECG (deg)');

Accepted Answer

William Rose
William Rose on 25 Feb 2023
If you want to use frequency analysis to examine the heart rate frequencies, you will need a lot of beats. 300 seconds is the minimum re ommended duration for analysis of heart rate variability.
The ECG has fast components, associated with the QRS complex, and slow components associated ith heart rate variability.
If you want to use frequency analysis to examine the heart rate and its variability, you might want to check out this paper: Spectral analysis of point processes, Rose & Knight, Med.Sci.SportsExercise 2011.
Can you upload your file, ECG1(.mat)?
  9 Comments
collegestudent
collegestudent on 27 Feb 2023
Thank you for this. Is there a way to determine bandwidth of signal and average heart rate using MATLAB?
William Rose
William Rose on 28 Feb 2023
Yes you can analyze heart rate data in the frequency domain with Matlab.
To get average heart rate, simply count the number of R waves in a given duration, such as 1 minute. Search Matlab Answers and the File Exchange for how to find the R waves. Learn how to use findpeaks() by reading the help and trying the examples.
The term "bandwidth" is not generally applied to heart rate because it is not useful.
The EKG includes fast and slow components, which convery different types of information. The fast components create the wave shape details: S-T segment height; duration of intervals such as P-R, Q-T, etc. These details are essential for diagnosing many types of condtions, when done with a 12 lead EKG. The frequency domain analysis of the raw EKG has not yielded important clinical insights or tools. The analysis is best done on the time domain signal.
The slow components of the EKG (slower than the HR frequency) pertain to how HR changes with time. This is referred to as HR variability. For this kind of study, you typically collect data for 5 minutes or more. You determine the beat times (the R wave times). There are many research articles about HR variability. See here for an introduction. See here for how to compute the spectrum.

Sign in to comment.

More Answers (0)

Categories

Find more on ECG / EKG in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!