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


bug #60432: [octave forge] (signal) xcorr optional args in any positional order

Submitted by:  None
Submitted on:  Wed 21 Apr 2021 04:08:00 PM UTC  
Category:  Octave Forge Package Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  IK Proudler Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  5.2.0
Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

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


Wed 21 Apr 2021 08:22:13 PM UTC, comment #3: 

Ok, thanks, confirmed. Agree that input validation should be updated, and also argument parsing needs to allow for 'maxlag' and 'scale' arguments to be swapped based on their type.

Should also include new corresponding tests of input validation and a test to show that different argument ordering produces an identical result.

Mike Miller <mtmiller>
Project Administrator
Wed 21 Apr 2021 06:46:40 PM UTC, comment #2: 

My apologies, I should have been more careful proof-reading my post.

The call that produced the error is:


Wed 21 Apr 2021 05:53:55 PM UTC, comment #1: 

Your example works for me with the current signal package:

M = rand (1000);
Nlag = 128;
R = xcorr (M, Nlag, 'coeff');

Can you give a more complete example that shows the error you encountered?

Mike Miller <mtmiller>
Project Administrator
Wed 21 Apr 2021 04:08:00 PM UTC, original submission:  

The documentation for xcorr is misleading or there is a logical error in the code.

'help xcorr' says:

-- Function File: [R, LAG] = xcorr ( X )
-- Function File: ... = xcorr ( X, Y )
-- Function File: ... = xcorr ( ..., MAXLAG)
-- Function File: ... = xcorr ( ..., SCALE)

Thus, with M a matrix and Nlag an integer, the call


should work. However it returns an error:

error: xcorr: X must be a vector or matrix
error: called from
    xcorr at line 171 column 5

The relevant lines are:

169  ## check argument values
170  if isempty(X) || isscalar(X) || ischar(Y) || ! ismatrix(X)
171    error("xcorr: X must be a vector or matrix");

For my call to work, I think the boolean

ischar(Y) || ! ismatrix(X)

should be replaced with

ischar(Y) && ! ismatrix(X)

Alternatively, since the call


works, the help message needs to be changed so that MAXLAG comes before SCALE.



(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 None (Submitted the item)

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

    Only project members can vote.




    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-04-21 mtmiller Severity3 - Normal => 2 - Minor
        Item GroupUnexpected Error or Warning => Matlab Compatibility
        StatusWorks For Me => Confirmed
        Summary[octave forge] (signal) xcorr documentaion misleading or error in code => [octave forge] (signal) xcorr optional args in any positional order
    2021-04-21 mtmiller StatusNone => Works For Me
        Summaryxcorr documentaion misleading or error in code => [octave forge] (signal) xcorr documentaion misleading or error in code

    Back to the top

    Powered by Savane 3.6