[SciPy-user] Linear filter
Claes Hagstrom
Claes.Hagstrom at emw.ericsson.se
Tue Mar 5 01:23:14 CST 2002
I recently downloaded SciPy-0.1, which I found very interesting. As I
work with signal processing simulations, I tried the linear filter.
However, there seems to be something wrong either with the filter or
my way of using it. I tried the same simple calculations in Matlab as
well and got the results I expected. I would appreciate your comments.
Claes Hagström ( claes.hagstrom at emw.ericsson.se )
---------------------------
SciPy: Matlab:
from scipy import * b = [ 5 -1 ];
a = [ 1 0 ];
b = array([5.,-1.])
a = array([1.,0.]) x = [ 1 3 ; 5 7 ];
x(:,:,2) = [ 2 4 ; 6 8 ];
x = reshape(arange(8,typecode=Float)+1,(2,2,2))
c = filter(b,a,x,[],1);
c = signal.lfilter(b,a,x,0) d = filter(b,a,x,[],2);
d = signal.lfilter(b,a,x,1) e = filter(b,a,x,[],3);
e = signal.lfilter(b,a,x,2)
---------------------
>>> print a a =
[ 1. 0.]
>>> print b 1 0
[ 5. -1.]
b =
5 -1
>>> print x[:,:,0] x(:,:,1) =
[[ 1. 3.]
[ 5. 7.]] 1 3
>>> print x[:,:,1] 5 7
[[ 2. 4.]
[ 6. 8.]]
x(:,:,2) =
2 4
6 8
>>> print c[:,:,0] c(:,:,1) =
[[ 5. 0.]
[ 25. 0.]] 5 15
>>> print c[:,:,1] 24 32
[[ 10. 20.]
[ 28. 36.]]
c(:,:,2) =
10 20
28 36
>>> print d[:,:,0] d(:,:,1) =
[[ 5. 14.]
[ 0. 35.]] 5 14
>>> print d[:,:,1] 25 30
[[ 10. 18.]
[ 30. 34.]]
>>> d(:,:,2) =
10 18
30 34
>>> print e[:,:,0] e(:,:,1) =
[[ 5. 15.]
[ 0. 35.]] 5 15
>>> print e[:,:,1] 25 35
[[ 9. 17.]
[ 0. 33.]]
e(:,:,2) =
9 17
25 33
More information about the SciPy-user
mailing list