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

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

类别

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