[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #52086] t=1:5; t(zeros(0,1)+[1:2]) returns 0×2
From: |
Alois Schlögl |
Subject: |
[Octave-bug-tracker] [bug #52086] t=1:5; t(zeros(0,1)+[1:2]) returns 0×2 empty double matrix in Matlab |
Date: |
Fri, 22 Sep 2017 02:37:03 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 |
URL:
<http://savannah.gnu.org/bugs/?52086>
Summary: t=1:5; t(zeros(0,1)+[1:2]) returns 0×2 empty double
matrix in Matlab
Project: GNU Octave
Submitted by: schloegl
Submitted on: Fri 22 Sep 2017 06:37:02 AM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 4.2.1
Operating System: GNU/Linux
_______________________________________________________
Details:
Recently, I tried to convert some Matlab code to Octave. In Matlab
9.1.0.441655 (R2016b), this expression returned
t=1:5; t(zeros(0,1)+[1:2])
0×2 empty double matrix
In Octave 4.2.1 the expression fails with this error
error: operator +: nonconformant arguments (op1 is 0x1, op2 is 1x2)
Matlab R2013a fails with this error
Error using +
Matrix dimensions must agree.
If it is a 0x0 or 1x1, like this
t(zeros(1,0)+[1:2])
t(zeros(0,0)+[1:2])
Error using +
Matrix dimensions must agree.
the expression fails in Matlab R2016b as well.
In the present case, the empty matrix zeros(0,1) was the result of "find(..)",
and under special conditions it can support writing leaner code. One could
argue whether this needs fixing, but Octave should be aware of this.
Best,
Alois
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?52086>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #52086] t=1:5; t(zeros(0,1)+[1:2]) returns 0×2 empty double matrix in Matlab,
Alois Schlögl <=