-
Notifications
You must be signed in to change notification settings - Fork 0
/
p4122015.m
74 lines (61 loc) · 1.78 KB
/
p4122015.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
clc; clear all; close all;
load('100m.mat');
x=val(1,:);
ecg=x';
figure(1);
plot(ecg); grid on;
title('ecg wave'); xlabel('time (msec)'); ylabel('amplitude(mV)');
N=8; M=8;
k=input('enter the total no.of samples ');
% n=0:1:k;
figure
n=1:1:2*k;
for i=0:1:7
x=ecg(n); y=ecg(n+i+1); z=ecg(n+i);
y1=y-z; x2=y1.*y1; x3=abs(x2);
a(n)=x3*(N+i+1);
end
% disp(a);
plot(y1); grid on;
title('derivated'); xlabel('time(msec)'); ylabel('amplitude(mV)');
figure;
plot(a); grid on;
title('derivated, squared & integrated');
xlabel('time(msec)'); ylabel('amplitude(mV)');
% hold on;
figure
n=1:1:k;
% j=1:7 % plot(n,((a(n-j)/M)));
s1=a(n); s2=a(n+1); s3=a(n+2); s4=a(n+3); s5=a(n+4); s6=a(n+5);
s7=a(n+6); s8=a(n+7); s9=a(n+8); s10=a(n+9); s11=a(n+10);
s12=a(n+11); s13=a(n+12); s14=a(n+13); s15=a(n+14); s16=a(n+15);
s=(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13+s14+s15+s16)/16;
disp(s); plot(n,s); grid on; hold on;
title('moving averager'); xlabel('time(msec)'); ylabel('amplitude(mV)');
figure
v=hilbert(s);
subplot(4,1,1);
plot(n,real(v)); grid on; hold on;
title('hilbert transform real part = moving avg.');
xlabel('time(msec)'); ylabel('amplitude(mV)');
subplot(4,1,2);
stem(n,imag(v)); grid on; hold on;
title('hilbert transform imaginary part = zero crossings');
xlabel('time(msec)'); ylabel('amplitude(mV)');
%
z1=zeros(1,k);
for i=1:0.1:k
if s(i)>20000
z1(i)=1;
end;
end;
subplot(4,1,3); stem(z1); grid on; hold on;
z2=zeros(1,k);
for i=1:0.1:k-1
if z1(i)==1
if s(i)> s(i+1)
z2(i)=1;
end;
end;
end;
subplot(4,1,4); stem(z2); grid on; hold on;