Basic Graphics Question: Array of 1's and 0's

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

 채택된 답변

Paulo Silva
Paulo Silva 2011년 7월 11일

2 개 추천

imagesc(~foo)
colormap(gray)
or colormap('gray') just to be safe, in case you overwrite the variable gray with something else.

댓글 수: 2

William
William 2011년 7월 11일
Thank you!
Paulo Silva
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개)

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2011년 7월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by