adding noise to an ecg signal
48 views (last 30 days)
Show older comments
Hi,
I am trying to add 50Hz noise to an ECG signal (imported from ASCII file) so that I can test my 50Hz notch filter. I have plotted my ECG data and have designed my '50Hz noise sinusoid' but how do I go about adding the noise to the signal?
I am a novice at MATLAB so any help would be great.
PS - I have tried +, and plotting together but the problem seems to be about the matrices not matching?
Thanks in advance
Katherine
0 Comments
Answers (3)
Arturo Moncada-Torres
on 15 Jul 2011
I would do something like this:
% Sampling
fs = 1000;
Ts = 1/fs;
% Time vector
t = 1:Ts:10-Ts;
% Signal
f = 1; % Frequency [Hz]
a = 1; % Amplitude
signal = sin(2*pi.*t.*f); % Sample sinusoidal signal. Your ECG signal goes here.
% Noise
fNoise = 50; % Frequency [Hz]
aNoise = 0.25; % Amplitude
noise = aNoise*sin(2*pi.*t.*fNoise);
% Signal + Noise
signalNoise = signal + noise;
% Plots
figure();
subplot(3,1,1);
plot(t, signal);
xlabel('Time [s]');
ylabel('Amplitude');
title('Original signal');
subplot(3,1,2);
plot(t, noise);
xlabel('Time [s]');
ylabel('Amplitude');
title('Noise');
subplot(3,1,3);
plot(t, signalNoise);
xlabel('Time [s]');
ylabel('Amplitude');
title('Original signal + Noise');
The trick is that your noise signal must have the same length than your ECG signal. If you do it this way, you can warranty that. Try it and let me know if it works ;-)
9 Comments
Ganesh Makkapati
on 29 May 2020
actually a sinusoidal signal is adding to other sinusoidal signal
but the same not working instead same ecg signal is appearing
what could be the reason
Fangjun Jiang
on 15 Jul 2011
You must have you ECG signal data. You need to know the time step of the data,i.e. what is the elapsed time between the first data and second data. Then you need to know the length of your ECG signal, i.e. how many total time does your ECG signal last. Then you need to generate your noise signal use the same time step and generate the signal with the same length. Then you can simply add them together.
Do you have Simulink? If you do, it's much easier doing this in Simulink. You can use the FromWorkspace block to import your ECG signal, then add a periodical sinusoid noise. You don't need to worry about the length of the noise signal because it simply repeats again and again.
1 Comment
MD
on 10 Aug 2023
what is procedure for adding noise in ecg signal?. i use from file block to load ECG signal but i have d'not idea which block i introduce for noise and how i use filter for removing that noise ? if you any idea then please help me.
Umesh Pande
on 1 Jun 2016
Hello sir i am working on project to remove 50hz noise from ECG signal using TVLMS algorithm in Matlab can you guide me
0 Comments
See Also
Categories
Find more on Single-Rate Filters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!