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:  None Assigned to:  None
Originator Name:  Hans Reiser Originator Email:  -email is unavailable-
Open/Closed:  Open 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.


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.




    No changes have been made to this item

    Back to the top

    Powered by Savane 3.3