Borrar filtros
Borrar filtros

I would like to calculate heart rate by determining threshold for amplitude

2 visualizaciones (últimos 30 días)
I'd like to determing the QRS complex and draw rectange pulse and calculating hart rate
this code is what i write,
ecg =importdata ('ecg.txt');
sig=ecg(1:1400);
th=0.5;
count=0;
while (ecg> th)
count=count+1
end
  3 comentarios
mary keshtkar
mary keshtkar el 8 de Mzo. de 2023
I have no more information.
What if I just detect the QRS complex and count them?
Star Strider
Star Strider el 8 de Mzo. de 2023
See my Answer to your other Question. (There are still problems.)

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 8 de Mzo. de 2023
Try this:
% Optional initialization steps
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
ecg = importdata ('ecg.txt');
% Plot it
hFig = figure('Name', "Mary's ECG Signal", 'NumberTitle','off');
plot(ecg, 'b-', 'LineWidth', 2);
grid on;
xlabel('Sample Number', 'FontSize',fontSize);
ylabel('Signal Value', 'FontSize',fontSize)
title("Mary's ECG Signal", 'FontSize',fontSize)
% Define threshold
threshold = 0.5;
% Draw red lines across the thresholds.
yline(threshold, 'Color','r', 'LineWidth', 2);
yline(-threshold, 'Color','r', 'LineWidth', 2);
% Detect samples above threshold
inAPositivePeak = ecg > threshold;
% Count the number of positive peaks using bwlabel() in the Image Processing Toolbox.
[~, numPositivePeaks] = bwlabel(inAPositivePeak)
% Detect samples below a threshold
inANegativePeak = ecg < -threshold;
% Count the number of positive peaks using bwlabel() in the Image Processing Toolbox.
[~, numNegativePeaks] = bwlabel(inANegativePeak)
numPositivePeaks =
67
numNegativePeaks =
67

Categorías

Más información sobre Signal Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by