I have two versions of matlab one is 2015b and other is 2019a an operation ./ works in 2019a version but shows error matrix dimension mismatch in other 2015b version how come?

2 件のコメント

G A
G A 2019 年 6 月 15 日
per isakson
per isakson 2019 年 6 月 15 日
Most likely, you have made a mistake.
Can you show us a small example that throws this error in R2015b?

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

回答 (1 件)

Guillaume
Guillaume 2019 年 6 月 15 日
編集済み: per isakson 2019 年 6 月 15 日

0 投票

As per G A's comment, R2016b introduced automatic expansion for compatible array sizes. So, this works in R2016b or later:
x = [1, 2, 3] %1 x 3 row vector
y = [1; 1; 1] %1 x 3 column vector
z = x .* y %results in a 3 x 3 matrix
whereas it would fail in earlier versions.
To obtain the same result in earlier versions, use bsxfun
z = bsxfun(@times, x, y) %times is the functional name of .*

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

質問済み:

2019 年 6 月 15 日

編集済み:

2019 年 6 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by