help-octave
[Top][All Lists]

## complex output of pwelch

 From: Dmitri A. Sergatskov Subject: complex output of pwelch Date: Sun, 11 Mar 2007 00:56:27 -0600

```I noticed that at some moment I started getting
a complex output while doing
b = pwelch(a)
(which must be real).
The imaginary part is order of eps, but it is still an annoyance.
Should we put
Pxx = real(Pxx)
or there a better fix?

Dmitri.

p.s. This is an example on PPC OSX with hpc binary of octave 2.9.9:

octave:85> a=rand(16,1)
a =

0.23158279611096871
0.13475686431041639
0.11600916079881567
0.66193574795860100
0.28821200634388527
0.33950150091274417
0.03019499029666499
0.53297717647050991
0.00689129650662494
0.40770131753552846
0.76269004312663635
0.64289433700013687
0.48166615055996825
0.61059075641665395
0.09181145530069872
0.96806357024737943

octave:86> b=pwelch(a)
b =

0.694906450550431 - 0.000000000000000i
0.168157410845850 + 0.000000000000000i
0.044042332703282 + 0.000000000000000i
0.013559565644394 + 0.000000000000000i
0.020360604330361 + 0.000000000000000i
0.043678042332714 + 0.000000000000000i
0.030391967689350 + 0.000000000000000i
0.043206552245520 - 0.000000000000000i
0.069815447871313 - 0.000000000000000i

octave:87> max(b-real(b))
ans = 0.00000000000000e+00 + 2.82851361838824e-18i

```