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

2 次查看(过去 30 天)
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

回答(1 个)

Walter Roberson
Walter Roberson 2021-2-6
编辑:Walter Roberson 2021-2-6
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.

类别

Help CenterFile Exchange 中查找有关 Blue 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by