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

조회 수: 1 (최근 30일)
Conner Carriere
Conner Carriere 2021년 2월 6일
편집: Walter Roberson 2021년 2월 6일
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?

답변 (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에서 Red에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by