Elementwise Multiplication (Dot Multiplication) of Matrices

조회 수: 7 (최근 30일)
Chuck
Chuck 2018년 3월 24일
댓글: Star Strider 2018년 3월 24일
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 1x3 array with another 1x3 array, but not with a 4x1 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 1x3 array with a 4x1 array, getting a 3x4 array. However, you still cannot element-wise multiply a 1x3 array with a say, 2x2 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.

채택된 답변

Star Strider
Star Strider 2018년 3월 24일
It’s called ‘implicit expansion’, and was introduced in R2016b.
I can’t find a specific link to it. You can find it under Mathematics in the Release Notes (link) for R2016b.
  댓글 수: 3
James Tursa
James Tursa 2018년 3월 24일
편집: James Tursa 2018년 3월 24일
It applies to any two arrays as long as there is not a mismatch in an index where both dimensions are not equal to 1 and also not equal to each other. So not just for vectors and matrices.
Star Strider
Star Strider 2018년 3월 24일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by