FIR1 basic question
8 次查看(过去 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!