Matlab code I want to modify this code. The script should ask the user for the following inputs: Threshold Value and ECG file to be analyzed. without using findpeak function Output of the script: Plot of R peak widths as a function of time. % Peak Detection Script#1 clear all; close all; load '100m.mat'; % read binary Matlab file (*.mat) % data values in variable 'val'- you need to check % variable name in the given .mat file from the workspace y=val(2,:); % extract ECG magnitude from val, row 1 %t=val(1,:); % extract time magnitude from val, column 1 sampling_time =0.003; % time between data points in seconds t(1:length(y))=((1:length(y))-1)*sampling_time; % create a time array for ECG signal y by multiplying index with sampling rate %t=y*sampling_time; % either of time valuesline 13 or 15)can be used n=0; % initialize peak counter threshold=10; for i=1:length(y)-2 % start for loop if (y(i+1)-y(i)>0) & (y(i+2)-y(i+1) <= 0) & y(i) > threshold % conditional statement to find peaks % by comparing consecutive slopes % and setting threshold n=n+1; % counter for peak indices R(n)=i+1; % index value of the peak TR(n)=t(i+1); % time value of the peak else % add more statements if additional conditions have to be satisfied end % end for conditional loop end % end of for loop for j=1:n-1 RR(j)=(R(j+1)-R(j))*sampling_time; % calculating time interval between R peaks end %%%%%%%%%%%%%%%%%Plotting ECG Signal and the RR interval%%%%%%%%%%%%%% subplot (2, 1, 1); set(gca,'fontsize', 12); plot(t,y);

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Matlab code

I want to modify this code. The script should ask the user for the following inputs: Threshold Value and ECG file to be analyzed. without using findpeak function
Output of the script: Plot of R peak widths as a function of time.

% Peak Detection Script#1
clear all;
close all;
load '100m.mat'; % read binary Matlab file (*.mat)
% data values in variable 'val'- you need to check
% variable name in the given .mat file from the workspace
y=val(2,:); % extract ECG magnitude from val, row 1
%t=val(1,:); % extract time magnitude from val, column 1
sampling_time =0.003; % time between data points in seconds
t(1:length(y))=((1:length(y))-1)*sampling_time; % create a time array for ECG
signal y by multiplying index with sampling rate

%t=y*sampling_time; % either of time valuesline 13 or 15)can be used


n=0; % initialize peak counter
threshold=10;
for i=1:length(y)-2 % start for loop


if (y(i+1)-y(i)>0) & (y(i+2)-y(i+1) <= 0) & y(i) > threshold % conditional
statement to find peaks
% by comparing
consecutive slopes
% and setting
threshold


n=n+1; % counter for peak indices
R(n)=i+1; % index value of the peak
TR(n)=t(i+1); % time value of the peak

else
% add more statements if additional conditions have to be satisfied
end % end for conditional loop

end % end of for loop
for j=1:n-1

RR(j)=(R(j+1)-R(j))*sampling_time; % calculating time interval between R peaks

end
%%%%%%%%%%%%%%%%%Plotting ECG Signal and the RR interval%%%%%%%%%%%%%%
subplot (2, 1, 1);
set(gca,'fontsize', 12);
plot(t,y);
findpeaks(y,1/sampling_time,'MinPeakHeight',5);
title('ECG Signal');

 

xlabel ('time(sec)'); ylabel ('ECG magnitude (mV)');
subplot (2, 1, 2);
set(gca,'fontsize', 12);
plot(TR(1:n-1),RR);
title ('RR Interval');
xlabel ('time(sec)'); ylabel ('RR interval (sec)'); 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY