This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Removing High-Frequency Noise from an ECG Signal

This example shows how to lowpass filter an ECG signal that contains high frequency noise.

% Create one period of ECG signal
x = ecg(500).';
y = sgolayfilt(x,0,5);
Fs = 1000;
[M,N] = size(y);

% Initialize scopes
TS = dsp.TimeScope('SampleRate',Fs,...
                      'TimeSpan',1.5,...
                      'YLimits',[-1 1],...
                      'ShowGrid',true,...
                      'NumInputPorts',2,...
                      'LayoutDimensions',[2 1],...
                      'Title','Noisy and Filtered Signals');

% Design lowpass filter
Fpass  = 200;
Fstop = 400;
Dpass = 0.05;
Dstop = 0.0001;
F     = [0 Fpass Fstop Fs/2]/(Fs/2);
A     = [1 1     0     0];
D     = [Dpass Dstop];
b = firgr('minorder', F, A, D);
LP = dsp.FIRFilter('Numerator',b);

% Design Highpass Filter
Fstop = 200;
Fpass = 400;
Dstop = 0.0001;
Dpass = 0.05;
F = [0 Fstop Fpass Fs/2]/(Fs/2); % Frequency vector
A = [0 0     1     1]; % Amplitude vector
D = [Dstop   Dpass];   % Deviation (ripple) vector
b  = firgr('minord', F, A, D);
HP = dsp.FIRFilter('Numerator', b);

% Stream
tic;
while toc < 30
    x = .1 * randn(M,N);
    highFreqNoise = HP(x);
    noisySignal    = y + highFreqNoise;
    filteredSignal = LP(noisySignal);
    TS(noisySignal,filteredSignal);
end

% Finalize
release(TS)