I am an instructor of MATLAB at a university. And we traditionally taught that for element-wise multiplication to work, both dimensions (row and column number) of each matrices must be exactly the same. For instance, you could multiply a 1×3 array with another 1×3 array, but not with a 4×1 array. And it used to be like that, otherwise, it would give an error, saying "matrix dimensions must agree".
I just noticed that at least in MATLAB 2017a, you actually can multiply various sizes of arrays element-wise. For example, you can multiply a 1×3 array with a 4×1 array, getting a 3×4 array. However, you still cannot element-wise multiply a 1×3 array with a say, 2×2 array. What is the rule for the dimensions when doing elemnent-wise multiplication there? And in which edition of MATLAB this change occurred?
Thank you.
Best Answer