prasadadiga
Newbie level 2
hi everyone
i'm new to matlab , i've my project on the hear rate variability analysis(only linear)! so can any give algorithm as how to do it ! please forgive my dumbness!
i've done the following code !
%% Start and Clear Variables
close all
clear all
clc
disp(' WELCOME ')
disp(' %%%%%%%')
disp('Program to calculate ECG beats')
disp('-------------------------------')
%% User Inputs
file_name=input('Enter the name of the file with extention:','s');
sample_freq=input('Enter the sampling frequency of the signal:');
%% Load file
data=csvread(file_name);
dr=length(data);
%disp(dr);
%for i=1:dr
%end
%mx=max(data);
%disp(mx);
for i=2:dr
b(1)=data(1);
b(i)=data(i)-data(i-1); %first differentiation
if(b(i)<0)
b(i)=-1*b(i); %rectification
end
end
for i=3:dr
c(1)=b(1);
c(2)=b(2);
c(i)=(b(i)+2*b(i-1)+b(i-2)/4); %smoothening
end
for i=2:dr
d(1)=c(1);
d(i)=c(i)-c(i-1); %second differntiation
if d(i)<0
d(i)=-1*d(i); %rectification !!
end
end
for i=3:dr
e(1)=d(1);
e(2)=d(2);
e(i)=(d(i)+2*d(i-1)+d(i-2)/4); %smoothening
end
for i=1:dr
f(i)=(c(i)+e(i))/2;
end
maximval=0;
for i=1:dr
if f(i)>maximval
maximval=f(i);
end
end
for i=1:dr
if f(i)>=(0.4*maximval)
g(i)=200;
else
g(i)=0;
end
end
k=1;
for i=2:dr
if g(i-1)==0 && g(i)==200
h(k)=i;
k=k+1;
end
end
subplot(2,1,1),plot(e);
subplot(2,1,2),plot(g);
lt=length(h);
disp(lt);
for i=1lt-1)
rrnt(i)=h(i+1)-h(i);
end
%for i=1lt-1)
%disp(rrnt(i));
%end
nnmean=mean(rrnt);
disp(nnmean);
stdnn=std(rrnt);
disp(stdnn);
rmsssd=sqrt(mean(diff(rrnt))^2);
disp(rmsssd);
prasad
i'm new to matlab , i've my project on the hear rate variability analysis(only linear)! so can any give algorithm as how to do it ! please forgive my dumbness!
i've done the following code !
%% Start and Clear Variables
close all
clear all
clc
disp(' WELCOME ')
disp(' %%%%%%%')
disp('Program to calculate ECG beats')
disp('-------------------------------')
%% User Inputs
file_name=input('Enter the name of the file with extention:','s');
sample_freq=input('Enter the sampling frequency of the signal:');
%% Load file
data=csvread(file_name);
dr=length(data);
%disp(dr);
%for i=1:dr
%end
%mx=max(data);
%disp(mx);
for i=2:dr
b(1)=data(1);
b(i)=data(i)-data(i-1); %first differentiation
if(b(i)<0)
b(i)=-1*b(i); %rectification
end
end
for i=3:dr
c(1)=b(1);
c(2)=b(2);
c(i)=(b(i)+2*b(i-1)+b(i-2)/4); %smoothening
end
for i=2:dr
d(1)=c(1);
d(i)=c(i)-c(i-1); %second differntiation
if d(i)<0
d(i)=-1*d(i); %rectification !!
end
end
for i=3:dr
e(1)=d(1);
e(2)=d(2);
e(i)=(d(i)+2*d(i-1)+d(i-2)/4); %smoothening
end
for i=1:dr
f(i)=(c(i)+e(i))/2;
end
maximval=0;
for i=1:dr
if f(i)>maximval
maximval=f(i);
end
end
for i=1:dr
if f(i)>=(0.4*maximval)
g(i)=200;
else
g(i)=0;
end
end
k=1;
for i=2:dr
if g(i-1)==0 && g(i)==200
h(k)=i;
k=k+1;
end
end
subplot(2,1,1),plot(e);
subplot(2,1,2),plot(g);
lt=length(h);
disp(lt);
for i=1lt-1)
rrnt(i)=h(i+1)-h(i);
end
%for i=1lt-1)
%disp(rrnt(i));
%end
nnmean=mean(rrnt);
disp(nnmean);
stdnn=std(rrnt);
disp(stdnn);
rmsssd=sqrt(mean(diff(rrnt))^2);
disp(rmsssd);
prasad