Error using == Matrix dimensions must agree.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
2 Kommentare
Antworten (1)
Walter Roberson
am 3 Feb. 2019
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 Kommentare
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!