Basic Graphics Question: Array of 1's and 0's
1 回表示 (過去 30 日間)
古いコメントを表示
Hello all,
I have a pretty basic question, yet I'm still spinning my wheels a bit. Perhaps someone can help me.
I have an array of ones and zeros. The ones form a rectangular blocks. I would like generate a figure that shades the regions with 1's black and leaves the 0's white.
Ex:
foo = [0 0 0 0; 0 1 1 0; 0 1 1 0; 0 0 0 0; 0 1 1 0; 0 1 1 0; 0 0 0 0];
If plotting foo, I'd like to have a white rectangle with two black squares inside of it.
Thanks your assistance,
Will
0 件のコメント
採用された回答
Paulo Silva
2011 年 7 月 11 日
imagesc(~foo)
colormap(gray)
or colormap('gray') just to be safe, in case you overwrite the variable gray with something else.
2 件のコメント
Paulo Silva
2011 年 7 月 11 日
just for the record it wasn't that basic, I just stumble into that solution while messing around with patch and fill :)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Object Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!