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

 
 

bug #53211: detrend functionality missing for complex values

Submitter:  None
Submitted:  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 Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group Member
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");
     endif
   else
-    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");
   endif
 
   [m, n] = size (x);

Anonymous

 

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

Attach Files:
   
   
Comment:
   

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)
  •  

    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
    2019-02-27 mtmiller StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code