Error using == Matrix dimensions must agree.
2 ビュー (過去 30 日間)
古いコメントを表示
if(color ==[255 255 255 ] || color==[0 0 0] || color==[255 0 0] || color==[205 133 63] || color==[101 67 33] || color==[0 134 139] )
end
回答 (1 件)
Walter Roberson
2019 年 2 月 3 日
if color is a 1 x 1 x 3 array instead of a 1 x 3 array, then the == would fail in R2016a and earlier.
If color is a M x N x 3 array then comparing to a 1 x 3 array would fail in R2016a or earlier. In R2016b or later, it would only succed if N were 3 , so that you were comparing a M x 3 x 3 array to a 1 x 3 array, in which case it would be comparing rows to the given color value.
If your color array did happen to be the right size to match against a 1 x 3 array, or if you were to compare M x N x 3 to reshape([255 255 255], 1, 1, 3) then the == would not fail. However in such a case, the || would fail. || can only be used to "or" together conditions if each of the conditions is scalar.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!