0% found this document useful (0 votes)
66 views4 pages

EKG1 Signal Analysis and FIR Filter Design

This document describes designing and analyzing a finite impulse response (FIR) filter for an electrocardiogram (EKG) signal. It loads EKG data, designs an FIR filter using a Hamming window method, and analyzes the frequency response of the FIR filter by calculating the magnitude and phase response. It then applies the FIR filter to the EKG signal using convolution.

Uploaded by

Agoes Riyanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views4 pages

EKG1 Signal Analysis and FIR Filter Design

This document describes designing and analyzing a finite impulse response (FIR) filter for an electrocardiogram (EKG) signal. It loads EKG data, designs an FIR filter using a Hamming window method, and analyzes the frequency response of the FIR filter by calculating the magnitude and phase response. It then applies the FIR filter to the EKG signal using convolution.

Uploaded by

Agoes Riyanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SINYAL EKG1 MENTAH

close all
clc
clear all
addpath('F:\SINYAL PSD\sinyal EKG'); % isi dengan folder data EKG

Name = '[Link]'; % isi dengan nama file dalam *.mat


T = 10; % isi dengan durasi sinyal
Fs = 360; % isi dengan frekuensi sampling
dt = 1/Fs;
N = T*Fs;
t = (0:N-1)*dt;
load(Name);

%% plot
figure
plot(t,EKG1) % isi dengan nama variabel EKG
legend('EKG (mV)');
xlabel('waktu (sekon)');

FUNGSI FFT MENCARI SPECTRUM MAGNITUDE


%% analisis frekuensi

NFFT = 2^nextpow2(N);
Y = fft(EKG1,NFFT)/N;
f = Fs/2*linspace(0,1,NFFT/2+1);

figure
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Spektrum Magnitudo EKG')
xlabel('Frekuensi (Hz)')
ylabel('|Y(f)|')

DESIGN FILTER FIR


%% fir
wp = 0.24*pi; % frekuensi sisi passband
ws = 0.57*pi; % frekuensi sisi stopband

wc = (wp+ws)/2; % frekuensi cut-off

M=25; % panjang sinyal

n = [0:M-1];

hd = sin(wc*(n-(M-1)/2))./(pi*(n-(M-1)/2)); % respons impuls ideal


hd((M-1)/2+1)=wc/pi;
figure % plot respons impuls ideal
stem(n,hd)
title('Design Filter FIR')
ylabel('|Y(f)|')

DESIGN FILTER FIR DENGAN METODE WINDOW HAMMING


%%
w = 0.54-0.46*cos(2*pi*n/(M-1)); %window Hamming

h = w.*hd; % respons impuls filter

figure % plotting
stem(n,hd)
hold on
stem(n,h)
xlabel('n')
legend('h_{d}','h')
title('Design Filter FIR dengan Metode Window Hamming')
ylabel('|Y(f)|')

RESPONS FREKUENSI FIR FILTER


%% meningkatkan resolusi frekuensi
h1 = [h zeros(1,10e3-41)]; % menambah sampel menjadi 1000
h2 = [hd zeros(1,10e3-41)];

%% analisis frekuensi

NFFT = 2^nextpow2(length(h1)); % Next power of 2 from length of y


Y = fft(h1,NFFT);
Y2 = fft(h2,NFFT);
w1 = linspace(0,1,NFFT/2+1);

% group delay
hr = h.*[0:M-1];
h1r = [hr zeros(1,10e3-41)];
hdr = hd.*[0:M-1];
h2r = [hdr zeros(1,10e3-41)];

Yr = fft(h1r,NFFT);
Y2r= fft(h2r,NFFT);

tg = real(Yr(1:NFFT/2+1)./Y(1:NFFT/2+1));
tg2 = real(Y2r(1:NFFT/2+1)./Y2(1:NFFT/2+1));

% Plot respons frekuensi


figure
subplot(3,1,1)
plot(w1,20*log10(abs(Y(1:NFFT/2+1))))
hold on
plot(w1,20*log10(abs(Y2(1:NFFT/2+1))))
title('Respons Frekuensi FIR Filter')
ylabel('20log|H(\omega)| [dB]')
legend('Hamming Window','Rectangular Window')
subplot(3,1,2)
plot(w1,(angle(Y(1:NFFT/2+1))))
hold on
plot(w1,(angle(Y2(1:NFFT/2+1))))
ylim([-pi pi])
% title('Respons Frekuensi FIR Filter')
% xlabel('\omega_{norm}')
ylabel('\angleH(\omega) [rad]')
subplot(3,1,3)
plot(w1,tg)
hold on
plot(w1,tg2,'--')
% title('Respons Frekuensi FIR Filter')
xlabel('\omega_{norm}')
ylabel('\tau_{g}(\omega) [sampel]')
ylim([10 30])

FUNGSI KONVOLOSI DI COMMENT WINDOW (KETIKNYA)


a=h;
b=EKG1;
c=length(a);
d=length(b);
A=[a,zeros(1,d)];
B=[b,zeros(1,c)];
for i=1:c+d-1
E(i)=0;
for g=1:c;
if(i-g+1>0)
E(i)=E(i)+A(g)*B(i-g+1);
else
end
end
end
E
stem(E);
ylabel('E[d]');
xlabel('----->d');
%% Plot
T = 10 ; % isi dengan durasi sinyal
Fs = 360 ; % isi dengan frekuensi sampling
dt = 1/Fs;
N = T*Fs;
t = (0:N-1)*dt;
figure
plot(t,E(1:3600)) % isi dengan nama variabel EKG
legend('EKG (mV)');
xlabel('waktu (sekon)');

You might also like