[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: zp2sos error: cplxpair: could not pair all complex numbers
From: |
Mike Miller |
Subject: |
Re: zp2sos error: cplxpair: could not pair all complex numbers |
Date: |
Wed, 4 Jan 2017 22:59:29 -0800 |
User-agent: |
NeoMutt/20161126 (1.7.1) |
On Wed, Jan 04, 2017 at 21:30:14 -0800, hale812 wrote:
> Trying to calculate 6th order Chebyshev filter, getting an error out of the
> blue.
>
> The code:
> conf.stages=6; %Stages Chebyshev type2 filter
> conf.reject=40; %-dB out-of-band rejection
> conf.fsamp=1000; %1000Hz sampling frequency
> fpL=0.52915085925565918945068233369966; %Hz singular rejection frequency
> (pole) below the band
> fpH=491.55617297547132693580351769924; %Hz singular rejection frequency
> (pole) above the band
> %[fpL.*2 ./conf.fsamp,fpH.*2 ./conf.fsamp]=[0.00107164775883543,
> 0.00163819175474634]
>
> [z,p,k]=cheby2(conf.stages,conf.reject,[fpL.*2 ./conf.fsamp,fpH.*2
> ./conf.fsamp]);
>
> error: cplxpair: could not pair all complex numbers
> error: called from
> cplxpair at line 128 column 9
> cplxreal at line 52 column 9
> zp2sos at line 77 column 10
I'm guessing you omitted the last line in your script, something like
[sos, g] = zp2sos (z, p, k);
I get the same error as you with the latest version of Octave. There's
nothing wrong with your numbers or with what you're trying to do. We
could use some help from you to make Octave better instead of a
complaint and an expectation that it somehow gets better on its own.
Here is the reason for the error
>> [z, p, k] = cheby2 (6, 40, [fpL, fpH] .* 2 ./ 1000);
>> [~, idx] = sort (real (z));
>> z = z(idx).'
z =
-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.000860545419713i
0.999999629730722 - 0.000860545419685i
Now as you can see by the sorted pairs of zeros, the first 5 pairs are
within tolerance of each other. The last pair is not (the imaginary
values differ by about 2.8e-14), which is why the call to cplxpair
fails.
Is the error here due to cplxpair (should the default tolerance be
looser)? Or is the error due to the list of zeros returned by cheby2
(should the computed pairs be within tolerance to begin with)?
If you can help identify what Matlab does in this situation, and what
should be fixed and where, then maybe something can be done about it.
--
mike
- zp2sos error: cplxpair: could not pair all complex numbers, hale812, 2017/01/05
- Re: zp2sos error: cplxpair: could not pair all complex numbers,
Mike Miller <=
- Re: zp2sos error: cplxpair: could not pair all complex numbers, Mike Miller, 2017/01/05
- Re: zp2sos error: cplxpair: could not pair all complex numbers, Nicholas Jankowski, 2017/01/05
- Re: zp2sos error: cplxpair: could not pair all complex numbers, Nicholas Jankowski, 2017/01/05
- Re: zp2sos error: cplxpair: could not pair all complex numbers, Mike Miller, 2017/01/05
- Re: zp2sos error: cplxpair: could not pair all complex numbers, Nicholas Jankowski, 2017/01/05
- Re: zp2sos error: cplxpair: could not pair all complex numbers, Mike Miller, 2017/01/05
- Re: zp2sos error: cplxpair: could not pair all complex numbers, Ozzy Lash, 2017/01/05
- Re: zp2sos error: cplxpair: could not pair all complex numbers, Ozzy Lash, 2017/01/05
- Re: zp2sos error: cplxpair: could not pair all complex numbers, hale812, 2017/01/06