bugGNU Octave - Bugs: bug #54277, trapz ignores dim argument for a...


bug #54277: trapz ignores dim argument for a row vector

Submitter:  A.R. Burgers <arb>
Submitted:  Tue 10 Jul 2018 07:33:26 AM UTC
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.4.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Wed 11 Jul 2018 06:12:09 AM UTC, comment #6: 

Indeed matlab produces an error:

>> version
ans = ' (R2018a)'

>> trapz ([0:0.5:2;0:0.5:2].',[1:5;1:5].',1)
Error using trapz (line 62)
X must be a vector.

A.R. Burgers <arb>
Tue 10 Jul 2018 10:27:40 PM UTC, comment #5: 

I checked in a changeset to stable that fixes this.  See http://hg.savannah.gnu.org/hgweb/octave/rev/b09ff039e6ff.  Marking as fixed and closing report.

I'd still like to know if Matlab throws an error though.

Rik <rik5>
Group administrator
Tue 10 Jul 2018 09:46:37 PM UTC, comment #4: 

Okay, I see quite a few problems that need to be fixed.  Could someone test this in Matlab?

trapz ([0:0.5:2;0:0.5:2].',[1:5;1:5].',1)

I think it will produce an error.

Rik <rik5>
Group administrator
Tue 10 Jul 2018 07:34:03 PM UTC, comment #3: 

Matlab 2018b prerelease:

>> trapz (2, magic (3), 1)
ans =
    18    20    22

Philip Nienhuis <philipnienhuis>
Group Member
Tue 10 Jul 2018 03:11:38 PM UTC, comment #2: 

Since you have access to Matlab, could you also check this syntax?

trapz (2, magic (3), 1)

Rik <rik5>
Group administrator
Tue 10 Jul 2018 02:39:39 PM UTC, comment #1: 


It gets it correct for column vectors

octave:4> trapz (ones (3,1), 2)
ans =


I'll take a quick look.

Rik <rik5>
Group administrator
Tue 10 Jul 2018 07:33:26 AM UTC, original submission:  

octave's trapz behaves differently from matlab on row vectors, and appears to ignore the dim argument in this case.

with octave:

>> version
ans = 4.4.0x

>> trapz(ones(1,3),1)
ans = 2

On matlab

>> version
ans = ' (R2018a)'

>> trapz(ones(1,3),1)
ans =   0     0     0

A.R. Burgers <arb>


(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 rik5 (Posted a comment)
  • -email is unavailable- added by arb (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-07-10 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2018-07-10 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code