Error using == Matrix dimensions must agree.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 3 de Feb. de 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 comentarios
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!