필터 지우기
필터 지우기

implementing a "first difference" filter in Matlab defined by a difference equation.

조회 수: 4 (최근 30일)
Ben
Ben 2013년 10월 24일
댓글: Ben 2013년 10월 24일
Hi all
I am a student in a digital signal processing module and I am stuck on the final question of a lab session and I am not sure if my understanding is correct, i have already tried asking the lab tutor for help via email but no reply (he's a PHD candidate). the difference equation is shown below.
y[n] = x[n] - x[n -1]
He tells us its simple and can be achieved with one line of code.
My code is shown below, my understanding is its a second order difference equation.
FD = repmat(1/2,1,2); %repmat creates large matrix of 1 row by 2 columns (every coefficient value 1/2=0.5) FD_Filtered = firfilt(FD, x); %filtering input signal x with FD filter
Any advice will be greatly appreciated.
Thanks in advance,
Ben

답변 (2개)

Wayne King
Wayne King 2013년 10월 24일
No, I just mean filter(). A causal N-point moving average filter just has filter coefficients of 1/N
b = 1/N*ones(N,1);
  댓글 수: 1
Ben
Ben 2013년 10월 24일
편집: Ben 2013년 10월 24일
Ok thanks I understand now that this has two 1 and -1 right hence the y[n] = (1/1)x[n] + (1/-1)x[n-1] = x[n]-x[n-1]
therefore FD = [1 -1] (filter coefficients)

댓글을 달려면 로그인하십시오.


Wayne King
Wayne King 2013년 10월 24일
Why do you believe it's a second order difference equation?
Since it is a homework problem, I do not want to simply give you the answer, but look at filter()
He is correct in telling you that you can do it easily with one line of code.
  댓글 수: 1
Ben
Ben 2013년 10월 24일
the previous questions were to design moving average filters which were defined by a summation equation example;
y[n]= 1/5 ∑_(k=0)^4▒〖x[n-k]〗 (k going from 0 to 4 (4 = M-1) M=5)
for 5 point average so can the difference equation in the question be shown a similar way;
y[n]= 1/2 ∑_(k=0)^1▒〖x[n-k]〗 (k going from 0 to 1 when M-1=1 and M=2)
Do the filter coefficients seem correct?
By look at filter() do you mean firfilt()?
Thanks for advising

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by