help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: zp2sos error: cplxpair: could not pair all complex numbers


From: Nicholas Jankowski
Subject: Re: zp2sos error: cplxpair: could not pair all complex numbers
Date: Fri, 6 Jan 2017 08:59:55 -0500

On Thu, Jan 5, 2017 at 11:44 PM, Ozzy Lash <address@hidden> wrote:

> Here is a patch that makes this change.
>
> --- /home/lash/octave/signal-1.3.2/cheby2.m    2017-01-05 22:10:48.630452347
> -0600
> +++ cheby2.m    2017-01-05 22:37:24.415014904 -0600
> @@ -113,10 +113,11 @@
>    beta = cosh (phi) * cos (theta);
>    if (rem (n, 2))
>      ## drop theta==pi/2 since it results in a zero at infinity
> -    zero = 1i * C ./ cos (theta([1:(n - 1) / 2, (n + 3) / 2:n]));
> +    zero = 1i * C ./ cos (theta([1:(n - 1) / 2]));
>    else
> -    zero = 1i * C ./ cos (theta);
> +    zero = 1i * C ./ cos (theta([1:n/2]));
>    endif
> +  zero = [zero, conj(zero)];
>    pole = C ./ (alpha.^2 + beta.^2) .* (alpha - 1i * beta);
>
>    ## Compensate for amplitude at s=0
>
>

This does seem to fix the issue, but I also can't tell whether it's a
'correct' fix:


-----------------------------------
>> [z,p,k]=cheby2(6,40,[fpL.*2 ./1000,fpH.*2./1000]);z'
ans =

  -0.998687143937134 - 0.051224881988043i
  -0.999296201278521 - 0.037511359750325i
  -0.999905676503125 - 0.013734558486826i
   0.999994843220576 - 0.003211468862565i
   0.999997236381364 - 0.002351006089708i
   0.999999629730722 - 0.000860545419685i
   0.999994843220576 + 0.003211468862565i
   0.999997236381364 + 0.002351006089708i
   0.999999629730722 + 0.000860545419685i
  -0.998687143937134 + 0.051224881988043i
  -0.999296201278521 + 0.037511359750325i
  -0.999905676503125 + 0.013734558486826i

>> cplxpair(z)'
ans =

  -0.999905676503125 + 0.013734558486826i
  -0.999905676503125 - 0.013734558486826i
  -0.999296201278521 + 0.037511359750325i
  -0.999296201278521 - 0.037511359750325i
  -0.998687143937134 + 0.051224881988043i
  -0.998687143937134 - 0.051224881988043i
   0.999994843220576 + 0.003211468862565i
   0.999994843220576 - 0.003211468862565i
   0.999997236381364 + 0.002351006089708i
   0.999997236381364 - 0.002351006089708i
   0.999999629730722 + 0.000860545419685i
   0.999999629730722 - 0.000860545419685i

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

 Columns 1 through 3:

   1.000000000000000   1.999811353006250   1.000000000000000
   1.000000000000000   1.998592402557041   1.000000000000000
   1.000000000000000   1.997374287874269   1.000000000000000
   1.000000000000000  -1.999989686441153   1.000000000000000
   1.000000000000000  -1.999994472762729   1.000000000000000
   1.000000000000000  -1.999999259461444   1.000000000000000

 Columns 4 through 6:

   1.000000000000000   1.967506243219743   0.972881387742366
   1.000000000000000   1.923500197249973   0.927580075649338
   1.000000000000000   1.899456851014250   0.902325817320743
   1.000000000000000  -1.993570273311973   0.993582084086452
   1.000000000000000  -1.995281755784743   0.995298350815642
   1.000000000000000  -1.998255341271945   0.998276741178970

g =  0.896584733013340

-------------------------

recalling from earlier:

Matlab 2016b:
>>  [sos, g] = zp2sos (z, p, k)
sos =
  Columns 1 through 3
   1.000000000000000   1.999811353006249   0.999999999999999
   1.000000000000000   1.998592402557042   1.000000000000000
   1.000000000000000   1.997374287874268   0.999999999999998
   1.000000000000000  -1.999999259461443   0.999999999999999
   1.000000000000000  -1.999994472762730   1.000000000000001
   1.000000000000000  -1.999989686441154   1.000000000000001

  Columns 4 through 6
  1.000000000000000   1.899456851014267   0.902325817320760
  1.000000000000000   1.923500197249950   0.927580075649315
  1.000000000000000   1.967506243219755   0.972881387742377
  1.000000000000000  -1.993570273311965   0.993582084086443
  1.000000000000000  -1.995281755784758   0.995298350815657
  1.000000000000000  -1.998255341271938   0.998276741178964
g =
   0.896584733013338



reply via email to

[Prev in Thread] Current Thread [Next in Thread]