[Scilab-users] bug in function iir ?

Serge Steer Serge.Steer at inria.fr
Tue Feb 23 15:34:08 CET 2016


Your problem arises because one frequency value you ask for  corresponds 
exactly to a zero of hz.num
log(roots(hz.num))/(2*%pi)
so you want to compute the gain in dB of a zero value which is -inf

To avoid such problem you can let repfreq to do the frequency 
discretization.

[frq,repf]=repfreq  <repfreq.html>(hz)
or equivalently
[frq,repf]=repfreq  <repfreq.html>(hz,0,0.5)

in  this case the discretization uses  varying  frequency step
Serge

Le 23/02/2016 14:41, grivet a écrit :
> Le 23/02/2016 14:21, Serge Steer a écrit :
>> Please can you give more details :
>> value of Order and Fcutoff/Fs/2
>> and what you are doing with hz (because iir does not call dbphi)
>> Serge
> I am just running the example found in "how to design an elliptic 
> filter". Here is the code:
>
> Order    =  2;  // The order of the filter
> Fs       =  1000;  // The sampling frequency
> Fcutoff  =  40;    // The cutoff frequency
>
> // We design a low pass elliptic filter
> hz  =  iir  <iir.html>(Order,'lp','ellip',[Fcutoff/Fs/2  0],[0.1  0.1]);
>
> // We compute the frequency response of the filter
> [frq,repf]=repfreq  <repfreq.html>(hz,0:0.001:0.5);
> [db_repf,  phi_repf]  =  dbphi  <dbphi.html>(repf);
>
> // And plot the bode like representation of the digital filter
> subplot  <subplot.html>(2,1,1);
> plot2d  <plot2d.html>(Fs*frq,db_repf);
> xtitle  <xtitle.html>('Obtained Frequency Response (Magnitude)');
> subplot  <subplot.html>(2,1,2);
> plot2d  <plot2d.html>(Fs*frq,phi_repf);
> xtitle  <xtitle.html>('Obtained Frequency Response (Phase in degree)');
>
>
> with 'ellip' replaced by 'butt', and [Fcutoff/Fs/2 0] replaced 
> byFcutoff/Fs/2.
> I am beginning to use digital filters to treat some data. As my first 
> step, I try to run the examples in the help,how to design an elliptic 
> filter (using Scilab 5.5.1, Win7-64). This works . However, when I 
> select a Butterworth filter:
>>>          hz = iir(Order,'lp','butt',Fcutoff/Fs/2,[0.1 0.1]);
>>> I get this error message:
>>>
>>> Singularité de la fonction log ou tan.
>>> at line       6 of function dbphi called by :
>>> [db_repf, phi_repf] = dbphi(repf);
>>>
>>> What did I miss ?
>>> No bugs have been reported for function dbphi, but three similar 
>>> bugs are listed for iir.
>>> Any suggestion welcome.
>>> JPGrivet
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160223/f7ad1fa9/attachment.htm>


More information about the users mailing list