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

2 Ansichten (letzte 30 Tage)
Conner Carriere
Conner Carriere am 6 Feb. 2021
Bearbeitet: Walter Roberson am 6 Feb. 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

Antworten (1)

Walter Roberson
Walter Roberson am 6 Feb. 2021
Bearbeitet: Walter Roberson am 6 Feb. 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.

Community Treasure Hunt

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

Start Hunting!

Translated by