You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
Respiration rate and heart rate detection are vital parameters in monitoring an individual's health. Respiration rate refers to the number of breaths taken per minute, reflecting the efficiency of oxygen exchange in the lungs. It's a crucial indicator of respiratory health, cardiac function, and overall well-being. On the other hand, heart rate, measured in beats per minute, indicates the frequency of heart contractions, reflecting cardiovascular health and exertion levels.
Detection methods vary, from traditional manual counting to modern technologies like wearable sensors and medical devices. These technologies utilize various principles such as photoplethysmography (PPG), which measures blood volume changes, and accelerometers to detect movement associated with breathing and heartbeats. Accurate detection and monitoring of these rates aid in diagnosing respiratory and cardiovascular disorders, assessing fitness levels, and guiding medical interventions. They play a pivotal role in preventive healthcare, enabling timely intervention and improving quality of life.
a = arduino('COM4','Due');
y=0;
hPlot = plot(NaN);
intervalSize = 200;
currentInterval = 200;
t = 1; % number of samples
atInterval = 1;
beat_count = 0;
quitbutton = uicontrol('style','pushbutton',...
'string','Quit', ...
'fontsize',12, ...
'position',[10,2,50,20], ...
'callback','quitit=1;close');
quitit = 0;
bpmtext = uicontrol('style', 'text',...
'string', ['BPM: '],...
'fontsize', 12,...
'position', [80, 2, 100, 20]);
while(1)
k = 1;
while(t<currentInterval)
b=readVoltage(a, 'A0');
y=[y,b];
if ishandle(hPlot)
set(hPlot, 'YData', y);
else
break; % break out of the loop
end
xlabel('Samples')
ylabel('Voltage')
title('Phonocardiogram')
axis([currentInterval - intervalSize,currentInterval,0,3]);
%grid
t=t+k;
pause(0.002)
end
for m = 2 : length(b)-1
if(b(m) > b(m-1) & b(m) > b(m+1) & b(m) > 2.4)
%disp('Prominant peak found');
beat_count = beat_count + 1;
set(bpmtext, 'string', ['BPM: ',...
num2str(BPM_avg,4)]);
end
end
currentInterval = currentInterval + intervalSize;
atInterval = atInterval + 1;
if ~ishandle(hPlot)
break;
end
fs = 500;
N = length(b);
duration_in_seconds = N/fs;
duration_in_minutes = duration_in_seconds/60;
BPM_avg = beat_count/duration_in_minutes;
end
Cite As
Harshini (2026). RESPIRATION RATE AND HEART RATE DETECTION (https://www.mathworks.com/matlabcentral/fileexchange/164591-respiration-rate-and-heart-rate-detection), MATLAB Central File Exchange. Retrieved .
Acknowledgements
Inspired by: Heart Rate Detection using Arduino and MATLAB demo files
General Information
- Version 1.0.0 (1.7 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0 |
