フィルターのクリア

How to add noise to sine signal and filter it?

5 ビュー (過去 30 日間)
Nur Fauzira Saidin
Nur Fauzira Saidin 2015 年 8 月 25 日
編集済み: matico 2015 年 8 月 25 日
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!

回答 (1 件)

matico
matico 2015 年 8 月 25 日
編集済み: matico 2015 年 8 月 25 日
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.

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by