|
a |
|
b/data preprocessing_Matlab/onoffset.m |
|
|
1 |
function [ ind ] = onoffset( interval,mode ) |
|
|
2 |
%Function calculates on/off set of QRS complexe |
|
|
3 |
slope = []; |
|
|
4 |
for i = 2:length(interval)-1 |
|
|
5 |
slope(end+1) = interval(i+1)-interval(i-1); |
|
|
6 |
end |
|
|
7 |
% using MIN_SLOPE determine onset placement |
|
|
8 |
if strcmp(mode,'on') |
|
|
9 |
[m,ind] = min(abs(slope)); |
|
|
10 |
%display('onset detected'); |
|
|
11 |
elseif strcmp(mode,'off') |
|
|
12 |
slope_th = 0.2*max(abs(slope)); |
|
|
13 |
slope_s = find(abs(slope)>=slope_th); |
|
|
14 |
ind = slope_s(1); |
|
|
15 |
else |
|
|
16 |
display('wrong input, please select on/off set') |
|
|
17 |
end |
|
|
18 |
|
|
|
19 |
end |
|
|
20 |
|