band pass - matlab

 

code

% Create a signal sampled at 1 kHz for 1 second. The signal contains three tones, one at 50 Hz, another at 150 Hz, and a third at 250 Hz. The high-frequency and low-frequency tones both have twice the amplitude of the intermediate tone. The signal is embedded in Gaussian white noise of variance 1/100.
% https://ww2.mathworks.cn/help/signal/ref/bandpass.html#mw_4af987e6-9eef-463e-9b78-97eb8214df70

fs = 1e3;
t = 0:1/fs:1;
x = [2 1 2]*sin(2*pi*[50 150 250]'.*t) + randn(size(t))/10;
fft(x,fs)
% Bandpass-filter the signal to remove the low-frequency and high-frequency tones. Specify passband frequencies of 100 Hz and 200 Hz. Display the original and filtered signals, and also their spectra.
bandpass(x,[100 200],fs)

 

image

posted @ 2020-10-20 10:55  kaiming_ai  阅读(382)  评论(0编辑  收藏  举报