Disable Implicit Matlab R2016b Extension

Matlab R2016b comes with a ̶n̶e̶w̶ ̶f̶e̶a̶t̶u̶r̶e̶ monster that will kill us all: an implicit operator extension.

Basically, if you have matrix A and vector B, now you can just do A + B (without bsxfun or repmat ). Sounds great?

However, if you provide a column vector and row vector, it also works !!

Example:

 a = 1:4 % row vector b = (1:4)' % column vector % before R2016b: a + b Matrix dimensions must agree. % after R2016b: a + b ans = 2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8 

Expands both vectors and gives the matrix as a result !! This is very bad, since you can do completely unwanted operations without noticing.

So my question is: is there a way to disable the implicit extension and return a Matrix dimensions must agree error?

+5
source share

Source: https://habr.com/ru/post/1264578/


All Articles