Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to resolve given eror below?

2 ビュー (過去 30 日間)
Riya Bothara
Riya Bothara 2019 年 2 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Error using ==
Number of array dimensions must match for binary array op.

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 2 月 3 日
編集済み: Walter Roberson 2019 年 2 月 3 日
In R2016a or earlier, in order to use == to compare two arrays, the two arrays must be exactly the same size, or else one of them must be a scalar. For example [1 2 3 4] == 3 is okay, and [1 2 3 4] == [5 6 7 8] is okay, but [1 2 3 4] == [5; 6; 7; 8] is not okay because they do not have the same size (1 x 4 compared to 4 x 1) and neither one is a scalar.
In R2016b or later, in order to use == to compare two arrays, the two arrays can be exactly the same size, or else one of can be a scalar, or in every dimension in which the sizes do not agree, one of the two must be a singular dimension. For example [1 2 3 4] == [5 6; 7 8] is [1 4] compared to [2 2], and the 1 vs 2 for the first dimension is potentially okay, but the 2 vs 4 for the second dimension is not okay. But [1 2 3 4] == [5; 6; 7; 8] is [1 4] compared to [4 1], and 1 vs 4 for the first dimension is okay and 4 x 1 for the second dimension is okay. The result of [1 2 3 4] == [5; 6; 7; 8] would end up being a 4 x 4 array of logical values -- 1 compared to each of the four values, 2 compared to each of the four values, and so on.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by