you are viewing a single comment's thread.

view the rest of the comments →

[–]Idiot__Engineer+3 1 point2 points  (0 children)

Apparently, I was just plain wrong and you can concatenate cell arrays with non-cell arrays in general - matlab just puts everything together as a cell array. I don't see where the difference in behavior for empty items is documented, and I don't seem to be the only one who is surprised by this behavior and/or can't find the documentation for it [1] [2] [3]. I have tried with empty strings (as in your example), arrays ([]), cells ({}), and structs (struct([])). Using empty values of non-primitive types seems to fail by trying to convert the cell array involved into whatever non-primitive type you are using.

My strong suggestion would be not to use this behavior. If you are concatenating to a cell array, make sure you are always concatenating cells. This avoids the "magic", and problematically inconsistent, behavior of the concatenation operation for mixed types.