MATLAB Answers

Why didn't I get an error for my matrices?

2 ビュー (過去 30 日間)
Jessie
Jessie 2020 年 9 月 18 日
回答済み: Star Strider 2020 年 9 月 18 日
So I created a 3x3 matrix and created another 3x1 matrix. I thought adding matrices with different dimensions should result in an error but when I performed the addition it added the 3x1 matrix to the first column of the 3x3 matrix. Why did MATLAB do this?

  0 件のコメント

サインインしてコメントする。

回答 (2 件)


Star Strider
Star Strider 2020 年 9 月 18 日
You are seeing ‘Automatic Implicit Expansion’ introduced in R2016b (much to the consternation of many of us). Previously, the operation you wrote would have thrown an error, and to get the result you did would have required using the bsxfun function.
Note that it added the column vector ‘b’ to every column of your (3x3) matrix ‘A’, not only the first column.

  0 件のコメント

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by