Signal: zp2sos and cplxpair problem

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Signal: zp2sos and cplxpair problem

steven_ew
Hi

I am new to Octave but quite experience in Matlab. I am trying to get a script to run that creates and applies a Butterworth filter (it is a script I have used lots in Matlab).

The key lines are :

bandHz = [100 500];
sampleFreq = 1001;
nyquistFreq = 0.5 * sampleFreq;
w = bandHz / nyquistFreq;
[z,p,k] = butter(2, w);
[sos,g] = zp2sos(z,p,k);

However, when Octave gets to zp2sos it gives this error:

error: cplxpair: could not pair all complex numbers
error: called from:
error:   /usr/local/share/octave/3.6.1/m/general/cplxpair.m at line 126, column 9
error:   /home/steven/octave/signal-1.1.2/cplxreal.m at line 53, column 7
error:   /home/steven/octave/signal-1.1.2/zp2sos.m at line 70, column 10


I wondered if someone could help me go about fixing this problem or give some hint about where to start?


Thank you in advance for your help


Steven
Reply | Threaded
Open this post in threaded view
|

Re: Signal: zp2sos and cplxpair problem

Doug Stewart-4


On Mon, Apr 30, 2012 at 7:24 AM, steven_ew <[hidden email]> wrote:
Hi

I am new to Octave but quite experience in Matlab. I am trying to get a
script to run that creates and applies a Butterworth filter (it is a script
I have used lots in Matlab).

The key lines are :

bandHz = [100 500];
sampleFreq = 1001;
nyquistFreq = 0.5 * sampleFreq;
w = bandHz / nyquistFreq;
[z,p,k] = butter(2, w);
[sos,g] = zp2sos(z,p,k);

However, when Octave gets to zp2sos it gives this error:

error: cplxpair: could not pair all complex numbers
error: called from:
error:   /usr/local/share/octave/3.6.1/m/general/cplxpair.m at line 126,
column 9
error:   /home/steven/octave/signal-1.1.2/cplxreal.m at line 53, column 7
error:   /home/steven/octave/signal-1.1.2/zp2sos.m at line 70, column 10


I wondered if someone could help me go about fixing this problem or give
some hint about where to start?


Thank you in advance for your help


Steven


Confirmed, I get the same error message. 

The problem is that you are asking for a band pass filter and trying to do it with a second order filter.
Try a 4th order filter.

[z,p,k] = butter(4, w);

Doug

--
DAS

https://linuxcounter.net/user/206392.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Signal: zp2sos and cplxpair problem

Sergei Steshenko
In reply to this post by steven_ew

--- On Mon, 4/30/12, Doug Stewart <[hidden email]> wrote:

From: Doug Stewart <[hidden email]>
Subject: Re: Signal: zp2sos and cplxpair problem
To: "steven_ew" <[hidden email]>
Cc: [hidden email]
Date: Monday, April 30, 2012, 6:32 AM



On Mon, Apr 30, 2012 at 7:24 AM, steven_ew <[hidden email]> wrote:

Hi



I am new to Octave but quite experience in Matlab. I am trying to get a

script to run that creates and applies a Butterworth filter (it is a script

I have used lots in Matlab).



The key lines are :



bandHz = [100 500];

sampleFreq = 1001;

nyquistFreq = 0.5 * sampleFreq;

w = bandHz / nyquistFreq;

[z,p,k] = butter(2, w);

[sos,g] = zp2sos(z,p,k);



However, when Octave gets to zp2sos it gives this error:



error: cplxpair: could not pair all complex numbers

error: called from:

error:   /usr/local/share/octave/3.6.1/m/general/cplxpair.m at line 126,

column 9

error:   /home/steven/octave/signal-1.1.2/cplxreal.m at line 53, column 7

error:   /home/steven/octave/signal-1.1.2/zp2sos.m at line 70, column 10





I wondered if someone could help me go about fixing this problem or give

some hint about where to start?





Thank you in advance for your help





Steven


Confirmed, I get the same error message. 
The problem is that you are asking for a band pass filter and trying to do it with a second order filter.
Try a 4th order filter.
[z,p,k] = butter(4, w);
Doug
--
DAS
https://linuxcounter.net/user/206392.html



-----Inline Attachment Follows-----

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave

First of all, the error message is not clear.

Secondly, cascaded 1-st order HPF and LPF can form a BPF, though a low Q one. And the resulting BPF will be 2-nd order one.

Regards,
  Sergei.

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Signal: zp2sos and cplxpair problem

Doug Stewart-4


On Mon, Apr 30, 2012 at 9:49 AM, Sergei Steshenko <[hidden email]> wrote:

--- On Mon, 4/30/12, Doug Stewart <[hidden email]> wrote:

From: Doug Stewart <[hidden email]>
Subject: Re: Signal: zp2sos and cplxpair problem
To: "steven_ew" <[hidden email]>
Cc: [hidden email]
Date: Monday, April 30, 2012, 6:32 AM



On Mon, Apr 30, 2012 at 7:24 AM, steven_ew <[hidden email]> wrote:

Hi



I am new to Octave but quite experience in Matlab. I am trying to get a

script to run that creates and applies a Butterworth filter (it is a script

I have used lots in Matlab).



The key lines are :



bandHz = [100 500];

sampleFreq = 1001;

nyquistFreq = 0.5 * sampleFreq;

w = bandHz / nyquistFreq;

[z,p,k] = butter(2, w);

[sos,g] = zp2sos(z,p,k);



However, when Octave gets to zp2sos it gives this error:



error: cplxpair: could not pair all complex numbers

error: called from:

error:   /usr/local/share/octave/3.6.1/m/general/cplxpair.m at line 126,

column 9

error:   /home/steven/octave/signal-1.1.2/cplxreal.m at line 53, column 7

error:   /home/steven/octave/signal-1.1.2/zp2sos.m at line 70, column 10





I wondered if someone could help me go about fixing this problem or give

some hint about where to start?





Thank you in advance for your help





Steven


Confirmed, I get the same error message. 
The problem is that you are asking for a band pass filter and trying to do it with a second order filter.
Try a 4th order filter.
[z,p,k] = butter(4, w);
Doug
--
DAS
https://linuxcounter.net/user/206392.html



-----Inline Attachment Follows-----

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave

First of all, the error message is not clear.

Secondly, cascaded 1-st order HPF and LPF can form a BPF, though a low Q one. And the resulting BPF will be 2-nd order one.

Regards,
 Sergei.


I took another look at this problem.
It is the same in Octave 3.2.3 so it is not new.

The filter that is being designed is not practical in my opinion. 
The sample freq=1001 therefor nyquist is  500.5 and the upper corner freq. is at 500 with a 2 pole roll off!!
If we set the upper corner freq. to 499.99 then the program runs OK.
If we go to a higher order filter the problem also goes away.
If we go to a sample freq of 1002 the problem goes away.

So in conclusion 
1) the program does not crash
2) the particular filter is not practical. (Why have a corner freq. at .99 of nyquist?)
3) the complex numbers seem to be very close to each other and the software reports that-
  " could not pair all complex numbers" 

I don't intend to spend any more time on this. ( I think it is a corner case that is not too important)
Others may try to fix it.

Doug


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Signal: zp2sos and cplxpair problem

steven_ew
Dear Doug, Dear Sergei,

Thank you for your comments about my issue. Being new to Octave I am at least reassured that I hadn't done something wrong in compiling 3.6 and installing the packages. There certainly are a lot of dependencies.

I have experimented with the tests you did too Doug, and have the same results. It is interesting to me though that the complex pairing with those parameters worked in Matlab.

I admit, I am no expert in signal processing. It sounds like this filter is not ideal. I will go back to the person who designed it and discuss this issue.

Thanks again for your time and helpful responses.

Best wishes

Steven
Reply | Threaded
Open this post in threaded view
|

Re: Signal: zp2sos and cplxpair problem

Sergei Steshenko


--- On Wed, 5/2/12, steven_ew <[hidden email]> wrote:

> From: steven_ew <[hidden email]>
> Subject: Re: Signal: zp2sos and cplxpair problem
> To: [hidden email]
> Date: Wednesday, May 2, 2012, 2:51 AM
[snip]
> It is interesting to me though that the complex
> pairing with those
> parameters worked in Matlab.
[snip]
> Best wishes
>
> Steven
>

Then please file a bug. Compatibility with Matlab is an official Octave goal.

Bugs against packages and against Octave proper are filed at different places.

Regards,
  Sergei.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Signal: zp2sos and cplxpair problem

steven_ew
Happy to do so. As I am new to all this please could you indicate where to file a bug for a package? I went to
http://octave.sourceforge.net/archive.html
but this appears to indicate to send a message to this forum here?

Thank you

Steven
Reply | Threaded
Open this post in threaded view
|

Re: Signal: zp2sos and cplxpair problem

Sergei Steshenko




----- Original Message -----

> From: steven_ew <[hidden email]>
> To: [hidden email]
> Cc:
> Sent: Wednesday, May 2, 2012 9:37 PM
> Subject: Re: Signal: zp2sos and cplxpair problem
>
> Happy to do so. As I am new to all this please could you indicate where to
> file a bug for a package? I went to
> http://octave.sourceforge.net/archive.html
> but this appears to indicate to send a message to this forum here?
>
> Thank you
>
> Steven
>

I understand that you need to subscribe to https://lists.sourceforge.net/lists/listinfo/octave-dev and send bug reports to that list.

Regards,
  Sergei.

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave