Plot a Matrix with elements of only 1 and zeros
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Bjorn Gustavsson
2019-6-5
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!