[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, h
From: |
Amro |
Subject: |
[Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, horzcat, vertcat, and [] |
Date: |
Sat, 3 Dec 2016 12:53:36 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko |
URL:
<http://savannah.gnu.org/bugs/?49759>
Summary: Inconsistent concatenation with cat, horzcat,
vertcat, and []
Project: GNU Octave
Submitted by: amro_octave
Submitted on: Sat 03 Dec 2016 02:53:35 PM EET
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 4.2.0
Operating System: Any
_______________________________________________________
Details:
Concatenating an empty matrix 0x0 with a cell array produce the wrong result,
and is inconsistent depending on how we do it.
For example, in Octave 4.2.0 I get this:
>> A = [];
>> B = {1; 2};
>> C = [A; B]
C =
{
[1,1] = 1
[2,1] = 2
}
>> C = cat(1, A, B)
C =
{
[1,1] = [](0x0)
[2,1] = 1
[3,1] = 2
}
>> C = vertcat(A, B)
C =
{
[1,1] = [](0x0)
[2,1] = 1
[3,1] = 2
}
>> C = [A B]
C =
{
[1,1] = 1
[2,1] = 2
}
>> C = cat(2, A, B)
error: cat: dimension mismatch
>> C = horzcat(A, B)
error: horzcat: cat: dimension mismatch
On the other hand, in MATLAB R2016b I get this:
>> A = [];
>> B = {1; 2};
>> C = [A; B]
C =
2x1 cell array
[1]
[2]
>> C = cat(1, A ,B)
C =
2x1 cell array
[1]
[2]
>> C = vertcat(A, B)
C =
2x1 cell array
[1]
[2]
>> C = [A B]
C =
2x1 cell array
[1]
[2]
>> C = cat(2, A, B)
C =
2x1 cell array
[1]
[2]
>> C = horzcat(A, B)
C =
2x1 cell array
[1]
[2]
So it seems that in Octave using square-brackets to concatenate gives
different results than using the equivalent cat/horzcat/vertcat.
Note that if you replace the empty array with an empty cell array (i.e A={}
instead of A=[]) then Octave behaves correctly and give the same results as
MATLAB in all cases.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?49759>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, horzcat, vertcat, and [],
Amro <=
- [Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, horzcat, vertcat, and [], Rik, 2016/12/05
- [Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, horzcat, vertcat, and [], Guillaume, 2016/12/05
- [Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, horzcat, vertcat, and [], Amro, 2016/12/06
- [Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, horzcat, vertcat, and [], Mike Miller, 2016/12/06
- [Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, horzcat, vertcat, and [], Amro, 2016/12/07
- [Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, horzcat, vertcat, and [], Rik, 2016/12/13
- [Octave-bug-tracker] [bug #49759] Inconsistent concatenation with cat, horzcat, vertcat, and [], Rik, 2016/12/15