FIR1 basic question
7 ビュー (過去 30 日間)
古いコメントを表示
Hello Please help in FIR1 filtering. I clearly mentioned in the code about what I want to do.
clear all
clc
fm=100; % signal freq
fs=800; % sampling feq
fn=2*fm; %Nyquist rate
t=0:1/fs:0.1;
X = 2*sin(2*pi*fm*t) ;
% Here I created 100 hz sine wave
% addes some noise to it
Y=X+randn(1,length(X));
figure
plot(t,X)
hold on
plot(t,Y,'r')
% I need to have passband of the signal
% between 80Hz to 120 Hz
% So normalized frequencies are
fw1=fm/fn-0.1; % 80 Hz
fw2=fm/fn+0.1; % 120 Hz
% Coefficents for fir filter within passband
b = fir1(12,[fw1 fw2]);
figure
freqz(b,1,128)
% I convolved filter coefficients with noised signal
Filt_out=conv(b,Y);
figure
plot(Filt_out)
% Filtered Signal output
But Iam not getting filtered output..Please help to get the filtered output.
1 件のコメント
Jan
2011 年 10 月 2 日
Please explain the problem with any details. Do you get an error or does the results differ from your expectations?
Please read this about "clear all": http://www.mathworks.com/matlabcentral/answers/16484-good-programming-practice#answer_22301
採用された回答
Wayne King
2011 年 10 月 2 日
Hi, One major problem that you have is that you do not define your normalized frequencies correctly. If you want a passband between [80, 120]
Then your normalized frequencies are:
fp1 = (2*80)/fs;
fp2 = (2*120)/fs;
b = fir1(12,[fp1 fp2]);
Filt_out = filter(b,1,Y);
plot(t,X)
hold on
plot(t,Y,'r')
I would recommend designing your filter with fdesign.bandpass unless you have some compelling reason to use fir1
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Filter Design についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!