Fri 16 Dec 2016 01:17:01 AM UTC, comment #7:
I changed do_cat to strip out empty matrices when doing cell concatenation (http://hg.savannah.gnu.org/hgweb/octave/rev/0ab9eecbb165). I also added the test case in this bug report as a BIST test. Fixed, closing report.
|
Tue 13 Dec 2016 05:50:26 AM UTC, comment #6:
There are two code paths, never a good idea, for concatenation. One is through the parser and the other is through cat() in data.cc. The actual function is do_cat which gets called by cat, vertcat, and horzcat.
|
Wed 07 Dec 2016 03:36:23 PM UTC, comment #5:
@mtmiller
The type of the empty numeric matrix doesn't seem to matter.
Using "A = int32([])" or "A = single([])" in the previous MATLAB example gives the same results as before.
|
Tue 06 Dec 2016 05:48:43 PM UTC, comment #4:
I agree, I don't see any open reports about the *cat functions specifically.
The problem looks like it occurs when empty numeric arrays are converted into cell arrays for concatenation. Any homogeneous set collapses correctly:
But as soon as a mixed set is introduced, it adds empty elements to a non-empty cell array.
Amro - in Matlab, does the empty array have to be a double or can it be any empty numeric? What does your original example do with "A = int32([])" or "A = rand(0, 'single')"?
|
Tue 06 Dec 2016 02:03:05 PM UTC, comment #3:
Thank you for finding those previous reports.
It's actually interesting because none of the examples in those threads apply anymore in the latest Octave 4.2.0, as the behavior of concatenating using square-brackets is now consistent with that of MATLAB.
I don't know if this was fixed on purpose or simply a happy accident! Either way the issue that remains here is that cat/horzcat/vertcat in Octave are giving different results than the equivalent []-concatenation.
Regardless of whether this concat behavior is considered an undocumented MATLAB feature/bug or not, Octave should at least be consistent with itself no matter how concatenation is performed. So I think that the functions cat/horzcat/vertcat should be fixed to be conformant with [].
|
Mon 05 Dec 2016 05:17:57 PM UTC, comment #2:
Something similar was reported in bug #37086 and bug #35481.
|
Mon 05 Dec 2016 04:46:45 PM UTC, comment #1:
Isn't there already a bug report for this? Could you check to see whether this is a duplicate?
|
Sat 03 Dec 2016 12:53:35 PM UTC, original submission:
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:
On the other hand, in MATLAB R2016b I get this:
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.
|