bugGNU Octave - Bugs: bug #56172, concatenation of empty, 2-D, but...


bug #56172: concatenation of empty, 2-D, but not 0x0 arrays differs from Matlab

Submitter:  Rik <rik5>
Submitted:  Fri 19 Apr 2019 05:54:46 PM UTC
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Wed 26 Feb 2020 12:24:53 PM UTC, comment #1: 

I've hit this bug and I'm wondering if there is a simple workaround to 'collapse' the empty matrix dimensions?

I have to do something like:

rem_inds1 = find (strcmp ('lookingforthis', fnames));
rem_inds2 = find (strcmp ('nowthis', fnames));
rem_inds3 = find (strcmp ('thenthis', fnames));
rem_inds = [ rem_inds1, rem_inds2, rem_inds3 ];

Which fails because the output of find can't be concatenated when it's empty.

Richard <crobar>
Fri 19 Apr 2019 05:54:46 PM UTC, original submission:  

Yet another corner case involving concatenation.

In Octave, this code produces an error

[zeros(0,1), zeros(0,1), 1]
error: horizontal dimensions mismatch (0x2 vs 1x1)

However, in Matlab it succeeds with a result of [1], but it does throw a warning message.

Warning: this concatenation operation includes an empty array with an incorrect number of rows.
Concatenation including empty arrays will require all arrays to have the same number of rows in a future release.

The related code where the concatenated matrix is 0x0 works, and produces no error or warning.

[zeros(0,0), zeros(0,0), 1]

It seems like it would be useful to support current Matlab behavior because this syntax has probably been used in 25 years of m-file code.

Related bugs (resolved) are bug #31615 and bug #49759.

Rik <rik5>
Project Administrator


(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 crobar (Posted a comment)
  • -email is unavailable- added by rik5 (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 project members can vote.





    No changes have been made to this item

    Back to the top

    Powered by Savane 3.9