MATLAB: ECG signal artifact removing .

artifactecg signal

I have ECG signal has .mat extension I want to make good Baseline wander artifact removing by code, I know how to make it by fdatool , I just want it by codes to enhance it more ?

Best Answer

Try this:
Fs = 1000; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = [1.1 100]/Fn; % Passband Frequency (Normalised)
Ws = [0.1 101]/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple (dB)
Rs = 150; % Stopband Ripple (dB)
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs); % Filter Order
[z,p,k] = cheby2(n,Rs,Ws); % Filter Design
[sosbp,gbp] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(3)
freqz(sosbp, 2^16, Fs) % Filter Bode Plot
filtered_signal = filtfilt(sosbp, gbp, original_signal); % Filter Signal
Tweak the filter characteristics (most notably ‘Fs’ to be appropriate to your signal) to get the result you want. The sampling frequency ‘Fs’ is ideally above 250 Hz to use this filter.