How to add noise to sine signal and filter it?

8 vues (au cours des 30 derniers jours)
Nur Fauzira Saidin
Nur Fauzira Saidin le 25 Août 2015
Modifié(e) : matico le 25 Août 2015
Hi. I have two questions. 1) How to add noise with specific frequency (for example 2kHz-4kHz) to sine signal? 2) How to filter that signal (for example by using a bandpass filter) Please help me!

Réponses (1)

matico
matico le 25 Août 2015
Modifié(e) : matico le 25 Août 2015
Here I didn't use bandpass filters, but I just remove some harmonics from a signal using FFT and IFFT. The signal has got high 5th harmonics, which I want to include. Higher than that I want to remove. You can play with this in line: yFFT(7:end-7) = 0;
If you write:
yFFT(2:end-2) = 0;
Then you include only 0th harmonics -> this is offset (1.5 in my case).
yFFT(3:end-3) = 0;
You include offset + 1st harmonics. ...
yFFT(7:end-7) = 0;
Here are included offset and first 5 harmonics.
%%Create signal
clear; clc;
fSampling = 5000; % Hz
tSample = 1/fSampling;
T = 0:tSample:1-tSample; % 1s
Offset = 1.5;
F1 = 5; A1 = 3;
NoiseAmp = 0.5;
Sig = Offset + A1*sin(2*pi*F1*T) + NoiseAmp*(rand(1,length(T))-0.5);
%%FFT -> choose harmonics -> IFFT
yFFT = fft(Sig);
yFFT(7:end-7) = 0; % Play with numbers. Both must be the same
yFiltFFT = real(ifft(yFFT));
plot(T,Sig, T, yFiltFFT); grid;
Edit: Upps, now I see that you have specified frequency for a noise.

Catégories

En savoir plus sur Single-Rate Filters dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by