I recently stumbled upon the following behavior in MATLAB R2022a:
>> a = sparse(1,2,1)
a =
(1,2) 1
>> b = sparse(2,1,18)
b =
(2,1) 18
>> a+b
ans =
(2,1) 18
(1,2) 1
(2,2) 19
The presence of the (2,2) element with value 19 is quite puzzling. Intuitively, I would have expected to get either a zero (no element) or an error indicating that the vectors' sizes are not compatible. I couldn't find an explanation for this behavior in the documentation.
So, is this a bug or a feature?