Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Coding Matlab function "filter" in C++
Replies: 6   Last Post: Feb 11, 2013 11:03 AM

 Messages: [ Previous | Next ]
 Hossein Posts: 5 Registered: 4/3/08
Re: Coding Matlab function "filter" in C++
Posted: Feb 5, 2013 3:17 PM

Does anyone know what I am misunderstandning about Filter function concept with initial conditions of z0 = zi*y(1) as set in filtfilt function???
I tried to write my own as,

% assuming den & num has the same length
FilterOrder = (length(num)-1)/2;

for i=1:N
for j=1:2*FilterOrder
if i-j < 1
xo(j) = z0(j);
yo(j) = 0;
else
xo(j) = x(i-j);
yo(j) = y(i-j);
end
end
y(i) = num(1)*x(i) + sum(num(2:end).*xo') - sum(den(2:end).*yo');
end

Date Subject Author
11/29/05 Chris Heier
11/29/05 Peter Boettcher
11/30/05 Chris Heier
11/30/05 Peter Boettcher
11/30/05 Chris Heier
2/5/13 Hossein
2/11/13 Jan Simon