filtering ECG signal using 4th order low pass filter

2 views (last 30 days)
hello friends, i have written matlab code for 4th order butterworth filter of 70 hertz along with poles, zeros, transfer. Now, how can i apply this designed filter on an ecg signal? thanks. i am sharing my code here. clc; wc= 70; N= 4; K= 2.575; for k= 0:N-1 Sk(k+1)= wc*exp(1i*(pi/2))*exp(1i*(2*k+1)*(pi/(2*N)));
end
[NUM,DEN]=zp2tf([],Sk,K);
b0=DEN(end)*K;
Hs=tf(b0,DEN);
figure();
freqs(b0,DEN)
figure();
plot(Sk./10^2, 'x')
xlim([-10,10]);
title('Pole placement in s-plane')
%
for x = 1:10
disp(x)
end
[NUM,DEN]=lp2lp(NUM,DEN,wc);
fs=1000;
[NUMd,DENd]=bilinear(NUM,DEN,fs);
disp('NUMd='),disp(NUMd')
disp('DENd='),disp(DENd')
[Hd,wd]=freqz(NUMd,DENd);
Magd=abs(Hd);
subplot(2,1,1);
plot(wd/pi,Magd);
grid on;
title('Digital Lowpass Butterworth Filter');
ylabel('Amplitude response')
axis([0 0.2 0 1])
subplot(2,1,2);
plot(wd/pi,angle(Hd));
grid on;
axis([0 0.2 -200 200])
ylabel('Phase response')
xlabel('Frequency,[unit of pi]')
  4 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 21 Aug 2018
Is this following output (Magd)>> the final line for filter response?
Magd=abs(Hd);

Sign in to comment.

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 21 Aug 2018
Edited: KALYAN ACHARJYA on 21 Aug 2018
You can try in following way- For detail visit here
tic;
while toc<t %mention time of the signal to be observed here e.g. t=20,30 etc
filtered_ECG_Signal=mgd(Original_ECG_signal); %make the designed filer as a custom function or you can apply directly too.
TS(Original_ECG_signal,filtered_ECG_Signal);
end
% Finalize
release(TS)
  2 Comments
Pallabi dey
Pallabi dey on 21 Aug 2018
@ kalyan acharjya, thanks alot. i will try this one and let you know.
Pallabi dey
Pallabi dey on 29 Aug 2018
@kalyan acharjya, I need one more help. how can i plot the filtered signal and the original signal together as superimposed in the same figure? plase help. here is my code. i am not able to get both the plots together.
data= importdata('215_5.txt');
x = data(:, 1);
y = data(:, 2);
plot(x, y, 'b-', 'LineWidth', 2);
%%filter design
wc= 70;
N= 4;
K= 2.575;
for k= 0:N-1
Sk(k+1)= wc*exp(1i*(pi/2))*exp(1i*(2*k+1)*(pi/(2*N)));
end
[NUM,DEN]=zp2tf([],Sk,K);
b0=DEN(end)*K;
Hs=tf(b0,DEN);
figure();
freqs(b0,DEN)
figure();
plot(Sk./10^2, 'x')
xlim([-10,10]);
title('Pole placement in s-plane')
for x = 1:10
disp(x)
end
[NUM,DEN]=lp2lp(NUM,DEN,wc);
fs=1000;
[NUMd,DENd]=bilinear(NUM,DEN,fs);
disp('NUMd='),disp(NUMd')
disp('DENd='),disp(DENd')
[Hd,wd]=freqz(NUMd,DENd);
Magd=abs(Hd);
subplot(2,1,1);
plot(wd/pi,Magd);
grid on;
title('Digital Lowpass Butterworth Filter');
ylabel('Amplitude response')
axis([0 0.2 0 1])
subplot(2,1,2);
plot(wd/pi,angle(Hd));
grid on;
axis([0 0.2 -200 200])
ylabel('Phase response')
xlabel('Frequency,[unit of pi]')
%stream
tic;
ts1= timeseries((1:12000)',[0000 2000 4000 6000 8000 12000]);
while toc<30
Filtered_ECG_Signal= Magd(y);
ts1(y,filtered_ECG_Signal);
end
%Finalise
release(ts1)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!