%% Experiment No I
% Design highpass, lowpass and bandpass filters for filtering ECG
% signal([Link])
% (i) Import the signal in the workspace
load ecg;
% (ii) Design the filter using commands
bl,al, = butter(9,300/500,'low');
bh,ah, = butter(9,300/500,'high');
bb,ab, = butter(9,300 400,/1000);
% (iii) Use the filter coefficients to implement the filter
XLow = filter(bl,al,ecg);
XHigh = filter(bh,ah,ecg);
XBand = filter(bb,ab,ecg);
% (iv) Compare the unfiltered signal ECG and filtered signals
figure(1);
subplot(4,1,1);
plot(ecg);
title('Unfiltered ECG');
subplot(4,1,2);
plot(XLow);
title('Low Pass Filtered');
subplot(4,1,3);
plot(XHigh);
title('High Pass Filtered');
subplot(4,1,4);
plot(XBand);
title('Band Pass Filtered');
%% Experiment II
% Draw the FFT Plot of the EEG signal and ECG signal to study the frquency
% spectrum of both the signals
load ecg;
load 'eeg signal'
Fs = 100; % 100 hz Sampling frequency
T = 1/Fs; % Sample time
L = 3600; % Length of signal
t = (0:L-1)T; % Time vector
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(ecg,NFFT)/L;
f = Fs/2linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
subplot(4,1,1);
plot(ecg);
title('ECG Signal');
subplot(4,1,2);
plot(f,mag2db(2abs(Y(1:NFFT/2+1))))
title('FFT of ECG');
L = 6000; % Length of signal
t = (0:L-1)T; % Time vector
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(xn,NFFT)/L;
f = Fs/2linspace(0,1,NFFT/2+1);
subplot(4,1,3);
plot(xn);
title('EEG Signal');
subplot(4,1,4);
plot(f,mag2db(2abs(Y(1:NFFT/2+1))))
title('FFT of EEG');
%% Experiment No III
% Design bandpass filters for filtering EEG signal(eeg [Link])
% Importing the signal in the workspace
load 'eeg signal';
subplot(4,2,1 2,);
plot(xn);
title('THE EEG SIGNAL');
%%
% (i) Delta Signal (0.5 - 4 Hz)
bd,ad, = butter(2,0.5 4,/3000);
Xd = filter(bd,ad,xn);
subplot(4,2,3);
plot(Xd);
title('Delta (0.5 - 4 Hz)');
%%
% (i) Theta Signal (4 - 8 Hz)
bt,at, = butter(2,4 8,/3000);
Xt = filter(bt,at,xn);
subplot(4,2,4);
plot(Xt);
title('Theta (4 - 8 Hz)');
%%
% (i) Alpha Signal (8 - 13 Hz)
ba,aa, = butter(2,8 13,/3000);
Xa = filter(ba,aa,xn);
subplot(4,2,5);
plot(Xa);
title('Alpha (8 - 13 Hz)');
%%
% (i) Beta Signal (13 - 22 Hz)
bb,ab, = butter(2,13 22,/3000);
Xb = filter(bb,ab,xn);
subplot(4,2,6);
plot(Xb);
title('Beta (13 - 22 Hz)');
%%
% (i) Gamma Signal (13 - 30 Hz)
bg,ag, = butter(2,22 30,/3000);
Xg = filter(bg,ag,xn);
subplot(4,2,7);
plot(Xg);
title('Gamma (13 - 30 Hz)');
Lx4 8 peak uslng WaveleL Lransform
clc; clear all;
load [Link]
signal = val(1,1:1024);
%%Decomposing the signal
C,L, = wavedec(signal,10,'db6');
D = detcoef(C,L,4);
D1 = D;
%%Finding out the threshold value
thresh = .15 max(D);
for k = 1 : 74
if(D(k) <= thresh)
D(k) = 0;
end
end
x = mean(signal);
plot(signal-x);
hold
for P = 1:74
if((D(P) ~= 0))
plot(((P16)-90),275,'r^');
end
end
title('R peaks identification of ECG');
8 peak uslng normal meLhod
clc; clear all;
load [Link]
signal = val(1,1:1024);
plot(signal);
hold
threshold = max(signal) - (.15 max(signal))
for k = 1 : 1023
if(signal(k) threshold)
if((signal(k+1) < signal(k)) && (signal(k-1) < signal(k)))
plot(k, 1225, 'r^');
end
end
end