You are on page 1of 2

clc;

clear all;
close all;
x = ecg(500);
y = sgolayfilt(x,0,5);
Fs = 1000;
[M,N]=size(y);
Fpass = 200;
Fstop = 400;
Dpass = 0.05;
Dstop = 0.0001;
F = [0 Fstop Fpass Fs/2]/(fs/2);
A = [1 1 0 0];
D = [Dpass Dstop];
b = firgr('minord',F,A,D);
LP = dsp.FIRFilter('Numerator',b);
Fpass = 200;
Fstop = 400;
Dpass = 0.0001;
Dstop = 0.05;
F = [0 Fstop Fpass Fs/2]/(fs/2);
A = [0 0 1 1];
D = [Dstop Dpass];
b = firgr('minord',F,A,D);
HP = dsp.FIRFilter('Numerator',b);
tic;
while toc < 30
x = 0.1 * randn(M,N);
highFreqnoise = HP(x);
noisysignal = y + highFreqnoise;
filteredsignal = LP(noisysignal)
TS(noisysignal,filteredsignal);
end
release(TS)

y = sgolayfilt(x,order,framelen)
y = sgolayfilt(x,order,framelen,weights)
y = sgolayfilt(x,order,framelen,weights,dim)

Description
y = sgolayfilt(x,order,framelen) applies a Savitzky-Golay FIR smoothing filter to the data in
vector x. If x is a matrix, sgolayfilt operates on each column. The polynomial order, order, must be
less than the frame length, framelen, and in turn framelen must be odd. If order = framelen-1, the
filter produces no smoothing.
y = sgolayfilt(x,order,framelen,weights) specifies a weighting vector, weights, with
length framelen, which contains the real, positive-valued weights to be used during the least-squares
minimization. If weights is not specified, or if it is specified as empty, [], it defaults to an identity matrix.
y = sgolayfilt(x,order,framelen,weights,dim) specifies the dimension, dim, along which the filter
operates. If dim is not specified, sgolayfilt operates along the first nonsingleton dimension; that is,
dimension 1 for column vectors and nontrivial matrices, and dimension 2 for row vectors.

Examples

You might also like