FIR1 basic question

조회 수: 7 (최근 30일)
Raviteja
Raviteja 2011년 10월 2일
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
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
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개)

카테고리

Help CenterFile Exchange에서 Filter Design에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by