Plotting a grid with cells colored different depending on their value

9 ビュー (過去 30 日間)
Ross
Ross 2013 年 1 月 21 日
I have a 10x10 matrix, each element contains an integer value.
I'm looking for a way to visually represent this matrix. I want to have a grid (10x10) and each cell in the grid should be colored. Basically, each element should be the same number, and if the element is this number, I want a it to be green (for example); if it does not equal this value, I want it colored red.
I'm guessing this is possible, I just have no idea where to start with it!
Thanks.

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 1 月 21 日
You could use image() or scatter()

Image Analyst
Image Analyst 2013 年 1 月 21 日
編集済み: Image Analyst 2013 年 1 月 21 日
I agree with Walter. You can use image() or imshow(), combined with colormap() and colorbar.
But just as an interesting alternative, you might take a look at Steve Eddins's im2html() : http://blogs.mathworks.com/steve/2012/06/02/making-an-html-table-of-pixel-values-with-colored-cells/

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by