bugGNU Octave - Bugs: bug #53211, detrend functionality missing for...


bug #53211: detrend functionality missing for complex values

Submitted by:  None
Submitted on:  Fri 23 Feb 2018 08:24:02 PM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Hans Reiser Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.2.1
Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

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


Wed 27 Feb 2019 08:07:20 PM UTC, comment #1:

Thank you for the bug report and the example patch. I fixed this on the default branch of Octave along with more extensive changes to the function input validation

This fix will be part of Octave 6. If you want to use this function in the mean time, you can download the detrend.m function file from the hg repository and add it to your path.

Mike Miller <mtmiller>
Project Administrator
Fri 23 Feb 2018 08:24:02 PM UTC, original submission:

Matlab's detrend() function works fine for arrays of complex values, whereas code working fine with Matlab fails in Octave with the error "detrend: first input argument must be a real vector or matrix".

It seems to me that the function's actual functionality would be fine for complex arguments as well, so the following patch that simply adjusts the argument check seems to fix the problem and enhance Matlab compatibility:

--- /tmp/detrend.m 2018-02-23 21:18:07.000000000 +0100
+++ share/octave/4.2.1/m/signal/detrend.m 2018-02-23 21:17:55.000000000 +0100
@@ -39,7 +39,7 @@

function y = detrend (x, p = 1)

- if (nargin > 0 && isreal (x) && ndims (x) <= 2)
+ if (nargin > 0 && (iscomplex(x)||isreal (x)) && ndims (x) <= 2)
## Check p
if (ischar (p) && strcmpi (p, "constant"))
p = 0;
@@ -49,7 +49,7 @@
error ("detrend: second input argument must be 'constant', 'linear' or a positive integer");
- error ("detrend: first input argument must be a real vector or matrix");
+ error ("detrend: first input argument must be a real (or complex) vector or matrix");

[m, n] = size (x);



(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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-27 mtmiller StatusNone => Fixed
        Open/ClosedOpen => Closed

    Back to the top

    Powered by Savane 3.4