bugGNU Octave - Bugs: bug #50820, [octave forge] (signal) pwelch...


bug #50820: [octave forge] (signal) pwelch incorrectly discards DC component

Submitted by:  Shri <theillusiveman>
Submitted on:  Mon 17 Apr 2017 09:39:47 PM UTC  
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: NoneAssigned to: None
Originator Name: Open/Closed: Open
Release: 4.2.1Operating System: Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Mon 17 Apr 2017 10:10:05 PM UTC, comment #2:

Thanks for reply.
I suspected as much, it looked as if the DC was being subtracted. Adding "no-strip" argument results in the expected figure.

Yes, MATLAB does indeed not remove DC from the input. As a suggestion, would it be possible to remove the DC if a "strip" option is specified rather than keep if "no-strip" is specified? It will make things more uniform across Octave and MATLAB.

Shri <theillusiveman>
Mon 17 Apr 2017 09:59:41 PM UTC, comment #1:

I think the issue here is that in octave's pwelch the default
is to subtract mean from the signal, and in matlab's apparently not.

Try to add "no-strip" option:

[X,f]=pwelch(x,fs,0,fs,fs, "no-strip");


Dmitri A. Sergatskov <dasergatskov>
Mon 17 Apr 2017 09:39:47 PM UTC, original submission:

Current setup:
Windows 10, GNU Octave 4.2.1, Signal Package 1.3.2.

Procedure to replicate issue:

Generate any signal (or use existing one if desired) with a non-zero DC. Use the pwelch() method using one second window, no overlap to get the power spectrum. Observe the DC coefficient on the result.

What to expect?:

The DC term to be the actual average of the signal.

What happens?:

The DC term is zero.

Additional info:

I used the attached code to test for the issue. I generated a sinusoid with some DC offset. As a comparison, I generated the same graph on MATLAB. MATLAB has the correct DC term while Octave does not. See the attached graphs to observe the results. The graph name *_ML.png was generated in MATLAB. This shows the proper DC term. Octave does not.

Shri <theillusiveman>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #40424:  pwtest.m added by theillusiveman (259B - application/octet-stream)
file #40425:  PW_Test_ML.png added by theillusiveman (23KiB - image/png)
file #40426:  PW_Test_Oct.png added by theillusiveman (14KiB - image/png)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by jwe (Updated the item)
  • -unavailable- added by dasergatskov (Posted a comment)
  • -unavailable- added by theillusiveman (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 12 Aug 2017 07:01:43 PM UTCjweSummarypwelch incorrectly discards DC component=>[octave forge] (signal) pwelch incorrectly discards DC component
    Mon 17 Apr 2017 09:39:47 PM UTCtheillusivemanAttached File-=>Added pwtest.m, #40424
      Attached File-=>Added PW_Test_ML.png, #40425
      Attached File-=>Added PW_Test_Oct.png, #40426

    Back to the top

    Powered by Savane 3.1-cleanup1