Bandpass filtering with noise sequence

1 次查看(过去 30 天)
Hi guys, I am trying to make a filtered noise sequence with a nonzero spectrum between f1 = 100 and f2 = 300 Hz. However, my following code is producing a frequency vs magnitude graph that starts at 450? Here is the graph and the code:
% speccos.m plot the spectrum of a cosine wave
f1=100;
f2=300;
time=2; % length of time
Ts=1/1000; % time interval between samples
x=randn(1,time/Ts); % generate noise signal
freqs=[ 0.2 0.3 0.4 0.5 0.55 0.6];
amps=[0 0 1 1 0 0];
b=firpm(100,freqs,amps); % BP filter
ylp=filter(b,1,x); % do the filtering
figure(1),plotspec(ylp,Ts) % plot the output spectrum

回答(1 个)

Star Strider
Star Strider 2016-1-29
I don’t have the toolbox that includes the plotspec function, so I used freqz and redesigned your filter.
See if this does what you want:
f1=100;
f2=300;
time=2; % length of time
Ts=1/1000; % time interval between samples
x=randn(1,time/Ts); % generate noise signal
freqs=[ 0.0 0.2 0.3 0.5 0.6 1];
amps=[0 0 1 1 0 0];
b=firpm(100,freqs,amps); % BP filter
ylp=filter(b,1,x); % do the filtering
% figure(1),plotspec(ylp,Ts) % plot the output spectrum
figure(1)
freqz(b,1,1024,1/Ts) % Filter Bode Plot

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by