How to check if a matrix falls in between other matrix values

2 visualizaciones (últimos 30 días)
Conner Carriere
Conner Carriere el 6 de Feb. de 2021
Editada: Walter Roberson el 6 de Feb. de 2021
Lets say I have a matrix that is for the range of my values for red
Red = [212 0 0; 255 34 255];
I need to determine if another matrix falls between these two rows.
M = [232 12 0];
How would I do this
Better yet, is there a way that MATLAB would know that the M matrix is red? Could I define a way to find red, orange, white, yellow, blue, and green?
Thanks

Respuestas (1)

Walter Roberson
Walter Roberson el 6 de Feb. de 2021
Editada: Walter Roberson el 6 de Feb. de 2021
all(M >= Red(1,:) & M <= Red(2,:),3)
This would work for multiple rows of M matrix, producing one logical value per row of M.
There is no way that MATLAB would know that M is red except ways you (or someone) program. There is no built-in color identification method. Perception of color is individual, not universal, and there are no agreed boundaries for when something is or is not a particular color and not a different color.
Your Red would match [255 0 255] which few people would call red, being more likely to call magenta.

Categorías

Más información sobre Blue 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!

Translated by