필터 지우기
필터 지우기

Bandpass filter

조회 수: 2 (최근 30일)
Sampath reddy
Sampath reddy 2012년 3월 27일
I want to run a signal through bandpass filter, but the data is sent one by one.
t=0:0.0000001:1;
a=sin(2*pi*250*t)+sin(2*pi*500*t);
wn=[(240*0.00000001/2) (260*0.00000001/2)];
[B,A]=butter(2,wn,'bandpass');
for ii=0:length(t)
z(ii)=filter(B,A,a(ii));
end
I'm getting wrong data from the filter. What is wrong with the code??

채택된 답변

Jan
Jan 2012년 3월 27일
The wn contain very low frequencies. Is this really wanted?
You cannot filter scalars. Try to omit the loop:
z = filter(B,A,a);
If you really have a good reason to filter the data element by element, you have to consider the current status of the filter:
s = [];
z = zeros(1, length(t)); % pre-allocate!
for ii = 1:length(t) % Not 0:length(t) !
[z(ii), s] = filter(B, A, a(ii), s);
end

추가 답변 (0개)

카테고리

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