Reputation: 101
Suppose we have a 0-1 matrix, I want to generate a picture that is white in 0 entry and black in 1 entry, like the picture above.
Upvotes: 0
Views: 76
Reputation: 1163
You can use imagesc()
, with a gray colormap:
n = 10; % size of your matrix
a = randi(2, n, n) - 1; % random matrix containing only 1s and 0s
imagesc(a)
colormap gray
Upvotes: 2