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
0 件のコメント
回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Digital Filter Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!