clc;
clear all;
ecg=load('D:\12345.txt');
fs=242;
n=length(ecg); %ECG-iin data length
time=[0:n-1]/fs;
lp_hz=20; %lowpass phase
hp_hz=0.5; %highpass phase
k=5;
[b,a]=butter(k,lp_hz/(fs/2),'low');
ALF=filter(b,a,ecg); % after lowpass filter
[b,a]=butter(k,lp_hz/(fs/2),'high');
AHF=filter(b,a,ALF); %after highpass filter
%plot(time,ecg);
figure(1);
plot(time,ALF);
title('After lowpass filter');
%figure;
%plot(time,AHF);
%title('After highpass filter');
a=diff(ALF);
lastpot=a(length(a));
a(length(a)+1)=lastpot;
figure(2);
plot(time,a);
title('Difference');
sq=abs(a); % maybe square
figure(3);
plot(time,sq);
title('Square');
sm=smooth(sq,31); % 31-n orond sondgoi too bh yostoi
figure(4);
plot(time,sm);
title('Smooth');
%tegsh ontsogt poly bguulah
cr=5; % criteria
k=0;
points=sm;
for i=1:length(sm)
points(i)=0;
end
for i=1:length(sm)
if sm(i)>cr
points(i)=1;
if points(i-1)<points(i)
k=k+1;
end
end
end
figure(5);
plot(points);
title('fig5');
%Bosoo zuraas buhii graphic baiguulah
j=0;
hl=points;
for i=1:length(hl)
hl(i)=0;
end
for i=2:length(hl)-1
if (points(i-1)<points(i) && points(i)==points(i+1))
hl(i)=1;
j=j+1;
end
end
%shalgah
Rrange=find(hl==1);
peak=Rrange; %type is same as Rrange
for i=1:length(Rrange)-1
[x,y]=max(ALF(Rrange(i):Rrange(i+1)));
peak(i)=Rrange(i)+y-1;
end;
[x,y]=max(ALF(Rrange(313):length(ALF)));
peak(313)=Rrange(313)+y-1;
%hamgiin suuliin zavsar-s utga gargan avah
figure(6);
plot(time,ALF);
hold on;
plot(time(peak),ALF(peak),'ro');
title('fig6');
%line-r holboh
%t=0;
%j=1;
%max1=cr;
%for i=1:n-1
%end;
%figure;
%plot(time,tr);
%--------------- find the time of RRI in msec -------------
sampling=fs;
RRII=peak;
for i=1:length(peak)-1
RRII(i)=peak(i+1)-peak(i);
end
RRI=RRII;
for i=1:length(peak)-1
RRI(i)=(peak(i+1)-peak(i))/sampling;
end
%--------------------RR-resampling-------------------------
time1=(0:length(ecg)-1)*1/(sampling);
re_point=time1(length(time))/(1/10);
re_point=ceil(re_point);
re_time=(0:re_point-1)*(1/10);
temp=ones(length(re_time),1);
j=2;
temp1=find(re_time>peak(1)*(1/fs) & re_time<peak(length(peak))*(1/fs));
cross_peak=0;
k=0;
re_RRI=RRI;
for i=temp1(1):temp1(length(temp1))-1
k=k+1;
if re_time(i+1) >= time(peak(j)) && re_time(i-1) <= time(peak(j))
re_RRI(k)=((time(peak(j))-re_time(i-1))/RRI(j-1)) + ((re_time(i+1)-time(peak(j)))/RRI(j));
if cross_peak==0
cross_peak=1;
else
cross_peak=0;
j=j+1;
end
else
re_RRI(k)=((1/10)*2)/RRI(j-1);
end
end
%re_RRI(1)=0;
%re_RRI(length(re_RRI))=0;
figure(7);
plot(re_RRI);
%title('re_RRI');
%Fast Fourier Transform
Z=fft(re_RRI); %Fast Fourier Transform
%ReZ=real(Z);
%ImZ=-(Z-ReZ)*(Z-ReZ);
figure(9);
plot(Z);
xlabel('ReZ');
ylabel('ImZ');
axis([-2 2 -2 2]);
grid on;
title('Fast Fourier Transform to Z complex number');
Y=abs(Z);
f=Y;
f=cr/length(re_RRI)*(0:length(re_RRI)-1);
figure(8);
plot(f,Y);
grid on;
axis([0 0.6 0 8]);
没有合适的资源?快使用搜索试试~ 我知道了~
Bug_still_bosoo_zur.rar_Heart To Heart
共1个文件
m:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 153 浏览量
2022-07-15
10:20:31
上传
评论
收藏 1KB RAR 举报
温馨提示
heart rating to smoothing and transform Fast Fourier
资源详情
资源评论
资源推荐
收起资源包目录
Bug_still_bosoo_zur.rar (1个子文件)
Bug_still_bosoo_zur.m 3KB
共 1 条
- 1
刘良运
- 粉丝: 68
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0