bugGNU Octave - Bugs: bug #65614, Negative window values on Signal...


bug #65614: Negative window values on Signal pwelch

Submitter:  None
Submitted:  Fri 19 Apr 2024 04:46:42 PM UTC
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Ready For Test Assigned to:  lostbard
Originator Name:  Mariano Boragno Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * stable
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Sat 20 Apr 2024 11:54:46 AM UTC, comment #1: 
John Donoghue <lostbard>
Group Member
Fri 19 Apr 2024 04:46:42 PM UTC, original submission:  

The simple code below returns “error: pwelch: arg 2 (window) vector must be real and >=0”.

% create a simple signal
k = 1:128;
x = sin(2 * pi * k / 10);
% create the window function
win = flattopwin(128);
% calculate the spectrum with a flattop window
pwelch(x, win)

I can see in the pwelch.m file line 558 (https://sourceforge.net/p/octave/signal/ci/default/tree/inst/pwelch.m#l558) this condition is checked and enforced.
This is also consistent with pwelch's help:

      [real vector] of window-function values between 0 and 1; the
      data segment has the same length as the window.  Default
      window shape is Hamming.

I agree the window must be a real vector, but why does it require to be >= 0? As far as I understand there is no mathematical reason for that requirement and, in fact, falttop windows have negative values.

This is an easy fix on line 557 and, of course, the documentation:

- elseif ( is_win>1 && ( ~isreal(arg) || any(arg<0) ) )
+ elseif ( is_win>1 && ( ~isreal(arg) ) )




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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-04-20 lostbard StatusNone Ready For Test
        Assigned toNone lostbard

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code