Re: [Scilab-users] bug in function iir ?

2016-02-26 Thread Serge Steer

Le 25/02/2016 18:10, grivet a écrit :

Le 24/02/2016 21:40, Serge Steer a écrit :

Le 24/02/2016 11:30, grivet a écrit :
I appreciate your help; however, neither suggestion works: I still 
get the same error message.

The similar line
[frq,repf]=repfreq(hz,0.01,0.49);
has no problem

You are right the problem is exactly for the frequency 0.5 besause
exp(2*%pi*%i*0.5) -> - 1. + 1.225D-16i
and hz.num has 2 zeros  very near  -1

I checked the hz value with Matlab, the results are the same. So it 
seems that hz is ok. So it is probabily a probleme due to floating point 
computations procucing a zero value instead of a very small one.


Serge
please can you save the hz value using the Scilab save function and 
send the file?

Serge



Voila le code:
//filtre Butterworth
Order   = 2; // The order of the filter
Fs  = 1000; // The sampling frequency
Fcutoff = 40;   // The cutoff frequency

// We design a low pass Butterworth filter
hz = iir(Order,'lp','butt',Fcutoff/Fs/2,[0.1 0.1]);

// We compute the frequency response of the filter
[frq,repf]=repfreq(hz,0,0.5);
[db_repf, phi_repf] = dbphi(repf);

// And plot the bode like representation of the digital filter
subplot(2,1,1);
plot2d(Fs*frq,db_repf);
xtitle('Obtained Frequency Response (Magnitude)');
subplot(2,1,2);
plot2d(Fs*frq,phi_repf);
xtitle('Obtained Frequency Response (Phase in degree)');

iir est sauvegardé dans "svgd_iir" joint (binaire).

Cordialement,
JP Grivet



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] bug in function iir ?

2016-02-25 Thread grivet

Le 24/02/2016 21:40, Serge Steer a écrit :

Le 24/02/2016 11:30, grivet a écrit :
I appreciate your help; however, neither suggestion works: I still 
get the same error message.

The similar line
[frq,repf]=repfreq(hz,0.01,0.49);
has no problem
please can you save the hz value using the Scilab save function and 
send the file?

Serge



Voila le code:
//filtre Butterworth
Order   = 2; // The order of the filter
Fs  = 1000; // The sampling frequency
Fcutoff = 40;   // The cutoff frequency

// We design a low pass Butterworth filter
hz = iir(Order,'lp','butt',Fcutoff/Fs/2,[0.1 0.1]);

// We compute the frequency response of the filter
[frq,repf]=repfreq(hz,0,0.5);
[db_repf, phi_repf] = dbphi(repf);

// And plot the bode like representation of the digital filter
subplot(2,1,1);
plot2d(Fs*frq,db_repf);
xtitle('Obtained Frequency Response (Magnitude)');
subplot(2,1,2);
plot2d(Fs*frq,phi_repf);
xtitle('Obtained Frequency Response (Phase in degree)');

iir est sauvegardé dans "svgd_iir" joint (binaire).

Cordialement,
JP Grivet



svgd_iir
Description: Binary data
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] bug in function iir ?

2016-02-24 Thread Serge Steer

Le 24/02/2016 11:30, grivet a écrit :
I appreciate your help; however, neither suggestion works: I still get 
the same error message.

The similar line
[frq,repf]=repfreq(hz,0.01,0.49);
has no problem
please can you save the hz value using the Scilab save function and send 
the file?

Serge
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  (hz)
or equivalently
[frq,repf]=repfreq  (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






___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] bug in function iir ?

2016-02-24 Thread grivet
I appreciate your help; however, neither suggestion works: I still get 
the same error message.

The similar line
[frq,repf]=repfreq(hz,0.01,0.49);
has no problem
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 (hz) or equivalently 
[frq,repf]=repfreq (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




___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] bug in function iir ?

2016-02-23 Thread Serge Steer
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  (hz)
or equivalently
[frq,repf]=repfreq  (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  (Order,'lp','ellip',[Fcutoff/Fs/2  0],[0.1  0.1]);

// We compute the frequency response of the filter
[frq,repf]=repfreq  (hz,0:0.001:0.5);
[db_repf,  phi_repf]  =  dbphi  (repf);

// And plot the bode like representation of the digital filter
subplot  (2,1,1);
plot2d  (Fs*frq,db_repf);
xtitle  ('Obtained Frequency Response (Magnitude)');
subplot  (2,1,2);
plot2d  (Fs*frq,phi_repf);
xtitle  ('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@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] bug in function iir ?

2016-02-23 Thread grivet

Hello,
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@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users