"See" max 2nd-to-max values per column (by coloring entry)
3 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 26 Aug 2019
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.
0 Comments
See Also
Categories
Find more on Data Distribution Plots 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!