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

1 view (last 30 days)
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

Answers (1)

Walter Roberson
Walter Roberson on 6 Feb 2021
Edited: Walter Roberson on 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.

Categories

Find more on Linear Model Identification in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!