Skip to content

Commit 8c432ef

Browse files
authored
Add files via upload
1 parent 1aaa955 commit 8c432ef

6 files changed

Lines changed: 51 additions & 0 deletions

File tree

ECG-problem resample.png

28.7 KB
Loading

EdgeEffect.m

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
%% Edge effect using resample
2+
3+
% This script shows the edge effect due to resampling operation in signals.
4+
% In addition, it presents two alternatives to fix it.
5+
6+
% Author: MSc. David Castro Piñol
7+
8+
clear; close all; clc;
9+
load ecgSignal;
10+
Fs = 250;
11+
newFs = 360;
12+
13+
n = 0:length(ecgSignal)-1;
14+
t1 = n*1/Fs;
15+
16+
%% Problem Edge Effects
17+
18+
signalResampled = resample(ecgSignal,newFs,Fs);
19+
n2 = 0:length(signalResampled)-1;
20+
t2 = n2*1/newFs;
21+
22+
figure; plot(t1,ecgSignal,'b',t2,signalResampled,'r'); ylim([-4.7 -2.5]);
23+
xlabel('Time (s)'); ylabel('Signal'); legend('Original','Resampled', ...
24+
'Location','NorthWest');
25+
26+
%% First Alternative: mean normalization
27+
28+
ecgSignalMeanOff = ecgSignal - mean(ecgSignal);
29+
signalResampled = resample(ecgSignalMeanOff,newFs,Fs);
30+
n2 = 0:length(signalResampled)-1;
31+
t2 = n2*1/newFs;
32+
33+
figure; plot(t1,ecgSignalMeanOff,'bo-',t2,signalResampled,'r*-');
34+
xlabel('Time (s)'); ylabel('Signal'); legend('Zero Mean','Resampled', ...
35+
'Location','NorthWest');
36+
37+
%% Second Alternative: Flip and shift
38+
39+
L = ceil(length(ecgSignal)*newFs/Fs);
40+
flipedSignal = [flip(ecgSignal);ecgSignal;flip(ecgSignal)];
41+
signalResampled = resample(flipedSignal,newFs,Fs);
42+
43+
figure; subplot(211);plot(signalResampled,'b'); title('Flip and Shift ECG signal');
44+
hold on; plot(L:2*L-1,signalResampled(L:2*L-1),'r');
45+
cutSignal = signalResampled(L:2*L-1);
46+
subplot(212);plot(t2,cutSignal,'r'); title('Cutting signal');
47+
48+
49+
50+
51+

Zero-Mean-Off.png

32.1 KB
Loading

ecgSignal.mat

729 Bytes
Binary file not shown.

flip and shift.png

24.9 KB
Loading

zoom-over-edges.png

20.9 KB
Loading

0 commit comments

Comments
 (0)