I'm using the following commands in Matlab to filter data
[b,a]=butter(2,300.4/1e4);
yfilter=filtfilt(b,a,yin)
(filtfilt = phaseless filtering, by
filtering first from begin to end, then filtering a second time
from end to begin)
yin = measurement data, samp. freq 10 kHz
yfilter = filtered data
In Scilab I use the next commands
hz=iir(2,'lp','butt',[300.4/1e4 0],[0 0]);
y=yin(:)'
n=size(y,'c');
// first step: forward filtering
yf=flts(y,hz);
// second step: backward filtering
yf=yf(n:-1:1);
y=flts(yf,hz);
// create output vector
yfilter=y(n:-1:1)';
Why are the filtered data different ?
--
__o __o __o
--_`\<-_---_`\<-_---_`\<-_--------Eric van Oorschot------------
(_)/ (_) (_)/ (_) (_)/ (_) Rotterdam, the Netherlands
Public key at <http://www.nic.surfnet.nl/pgp>
In article <m2u36eg...@gildewg.xs4all.nl>,
Eric,
The main problem here is that "butter" in Matlab expects a cut-off
frequency in [0,1] where 1 is the Nyquist frequency. On the other
hand "iir" in Scilab expects a cut-off frequency in [0,0.5] where
0.5 is the Nyquist frequency. Looking at what you did above shows
me that you did not take this into account (it is, however, specified
in the online help for iir). Try comparing
[b,a]=butter(2,300.4/1e4);
and
hz=iir(2,'lp','butt',[300.4/1e4/2 0],[0 0]);
Hope this helps,
Carey Bunks
--
------------------------------------
Dr. Carey Bunks
Senior Scientist
BBN Corp.
70 Fawcett St, 15/2A
Cambridge, MA 02138
tel: 617-873-3028 fax: 617-873-2918
email: cbu...@bbn.com
------------------------------------
> [Posted and mailed]
> > Why are the filtered data different ?
> >
> >
>
> Eric,
>
> The main problem here is that "butter" in Matlab expects a cut-off
> frequency in [0,1] where 1 is the Nyquist frequency. On the other
> hand "iir" in Scilab expects a cut-off frequency in [0,0.5] where
> 0.5 is the Nyquist frequency. Looking at what you did above shows
> me that you did not take this into account (it is, however, specified
> in the online help for iir). Try comparing
>
> [b,a]=butter(2,300.4/1e4);
>
> and
>
> hz=iir(2,'lp','butt',[300.4/1e4/2 0],[0 0]);
>
> Hope this helps,
>
> Carey Bunks
>
It's partly correct what you say. Filtering in Matlab means dividing
by the Nyquist frequency, filtering in Scilab means dividing by
the sample frequency.
Matlab
[b,a]=butter(2,Fcutoff/(Fsample/2))
Scilab
hz = iir(2,'lp','butt',[Fcutoff/Fsample 0],[0 0])
Now I do get identical results.
Thanks,
Eric van Oorschot