Plot a Matrix with elements of only 1 and zeros
4 views (last 30 days)
Show older comments
Hello everyone,
I have a 50x10 matrix. Each element of this matrix has ONLY a value of either 0 or 1.
I am trying to plot this matrix so that one axis of the graph shows the number of columns and the other one shows number of rows (This will make a grid with 50*10 squares). Now i want each of these squares to have a a green color for a value of 1, and a red color for a value of zero, for the sake of the appearance (will be used in a report), I would prefer it to look like this:
(In my case it will be 50x10 squares instead of 5x5 squares)

0 Comments
Answers (1)
Bjorn Gustavsson
on 5 Jun 2019
Something like this ought to do it:
scatter(column,row,23,value,'filled')
colormap([1 0 0;0 1 0])
caxis([0 1])
HTH
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!