"See" max 2nd-to-max values per column (by coloring entry)

조회 수: 2(최근 30일)
Dave
Dave 2019년 8월 26일
답변: Walter Roberson 2019년 8월 26일
Hello, is there a way to "see" the max and second-to-max by columns in a 100x20 array? If, so, where would you see it? I understand array entries do not allow for color.Goal is to be able to quickly look if maxs are concentrated around a specific row.
This is similar to excel's conditional formatting where it paints a cell based on a condition
Thanks

답변(1개)

Walter Roberson
Walter Roberson 2019년 8월 26일
Create an 100x20 uint8 array. Assign 0 to the locations that are not the two max. Assign 1 to the locations that are the second maximas. Assign 2 to the locations that are the maximas.
Now image() the array, and invoke a colormap() of three colors, with the first row indicating the color for the entries that are not maxima, with the second row indicating the color for the entries that are the second maxima, and with the third row indicating the color for the entries that are the main maxima.
When you do this, pay attention to whether you want the high row numbers to appear at the top of the screen (YDir 'reverse' is default for image()) or at the bottom of the screen (YDir 'normal')
In the special case where you do not want to distinguish between maxima and second maxima, then you can create a logical array that is true for the maxima and second maxima. Then spy() the array.

Community Treasure Hunt

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

Start Hunting!

Translated by