I am doing a project on ECG arrythmia analysis using matlab.

  1. I have designed notch filter for removing 50 Hz noise but don't know how to add a 50 Hz powerline interference noise to a clean ECG signal?

  2. Also, I want to check whether noise is reduced in the filtered signal. Will Power spectral density using modified welch periodogram indicate whether noise is filtered or not?

  3. How can I compare which wavelet (e.g. db6) is best suited for ECG analysis?

  • 1
    $\begingroup$ I have the impression that ecg applications of wavelets should be well-described in current scientific literature, including which are the most suitable ones for ECG signals. $\endgroup$ Nov 27, 2012 at 15:52
  • $\begingroup$ I initially used a sampling frequency of 180 Hz. Is it enough? $\endgroup$
    – user3395
    Dec 3, 2012 at 18:10
  • $\begingroup$ With a sampling frequency of 180 Hz you can see any frequency up to 90 Hz (180 Hz / 2), so it is plenty for the noise. Whether it is enough for the ECG or not depends on the whether the highest non-trivial frequency in the ECG is less than 90 Hz or not. $\endgroup$
    – Jim Clay
    Dec 3, 2012 at 22:36
  • $\begingroup$ I want to add an EMG signal to ECG signal.. While adding will it be cancelled when it comes with out of phase? $\endgroup$
    – user41388
    Mar 29, 2019 at 18:23

3 Answers 3


1) Create a 50 Hz sinusoid and then simply add it to your ECG signal. You can control the power of the 50 Hz noise by multiplying the sinusoid by some gain factor (can be less than or more than 1) before you add it to the ECG.

2) I'm not familiar with the Welch periodogram, but if it displays the power spectral density then it should do fine. I would just do an FFT myself.


Since this question was asked a year and half ago, this is for memo:

I have designed notch filter for removing 50 Hz noise but don't know how to add a 50 Hz powerline interference noise to a clean ECG signal?

In MATLAB, let's say your original signal is original_ecg

sampling_frequency = 1000;
mains_coeff = 0.1;    Amplitude of mains line to change. Depends on your ECG signal.
time_step = 1/sampling_frequency;
max_time = 2;    % Duration of your signal in seconds.
t = time_step:time_step:max_time;    % This is our time vector.
mains_signal = cos(2*pi*60*t);       % 60Hz mains frequency. Depends.
dirty_signal = original_ecg + mains_coeff*mains_signal;

Here's an example signal from Physionet (100) where we add a noise of amplitude 0.1 and frequency of 60Hz. I've taken only 1second of the signal.

Original signal - MIT - 100

Sinusoidal noise to be added, I normalizd the axis to be the same as original

Dirty signal

Now, I made some assumptions to explain it roughly. I arbitrarily chose a 2 seconds duration, a 1000Hz sampling frequency, a 60Hz mains power.

Important: Make sure your noise is the same length as your signal.

Meaning: If your ecg contains 100000 values, your noise should contain as much as that, or you'll get an error.

Also important: Sometimes dimensions don't match (your time is a row, so is your mains. The data you import from MIT is a column that needs to be transposed simply row_vector = column_vector').

Okay, you are doing PLI (Power Line Interference) filtering. In a great, perfect world, it would be a sinusoïd, but in reality, there are spikes sometimes, arcs, etc. This is a pain in the butt. Feel free to add some impulses here and there in your mains to see how your code performs.

So, to test a denoising algorithm, you add a known noise to your signal, then pass it through your algorithm to get a denoised signal, then compare between original signal and denoised signal and look at performance parameters (SNR, distortion, etc). For the PSD, you see if the frequency range you are interested in isn't attenuated, for example.

How can I compare which wavelet (e.g. db6) is best suited for ECG analysis?

Well, this is kind of tedious: You do a state of the art. You read a lot of articles about where the field is at right now. There are some good academic articles burried in a ton of crap. Unfortunately, you'll have to sort them.

A lot of articles don't contain any value actually, only an tiny incremental benefit (many times the cost is that it gets computationally intensive to the point it doesn't justify the tiny increment).

It is a business, after all, where companies want their technology and algorithm protected, so as someone said, each time someone tries to go in the field, they need to reinvent the wheel in some way or another. And where publishers want a lot of articles published (nonobstant quality, often times).

So you test, a lot. You also get inspired applying things that aren't really applied in that discipline and try things out.


You could have a look at this paper: http://web.media.mit.edu/~dolguin/CISS05_Olguin_Bouchereau_Martinez.pdf

It also demonstrates how to artificially generate Power-line interference.

The power line noise interference is a frequency-varying sinusoidal with a center frequency of 60 Hz. In this work this interference will be modeled as

p(n) = A cos{2π[f0 + fv(n)]n + ψ} .


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.