imagesc replacement so I can see individual values colorcoded

1 回表示 (過去 30 日間)
MatG
MatG 2020 年 9 月 8 日
回答済み: Walter Roberson 2020 年 9 月 8 日
Is there a way to show the binary matrix b as points (say using scatter or a similar command) so I can see individual 1 and 0 values corresponding to different rows and columns with different colors for 0s and 1s similar to imagesc?
For instance the following script generates
a=rand(6,5);
b = a > 0.5;
% b is generated as follows
% 1 1 0 0 0
% 1 0 0 0 1
% 1 1 1 0 1
% 0 1 0 1 0
% 0 1 1 1 1
% 0 0 0 1 0
%replace the following so on the plot
% corresponding to (i,j) I can see a yellow "x" representing 1
% or a red "x" representing 0.
imagesc(b);colorbar;

回答 (2 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020 年 9 月 8 日
Hi,
A simple way is:
spy(b)

Walter Roberson
Walter Roberson 2020 年 9 月 8 日
imagesc(b);
colormap([1 0 0; 1 1 0]); %red and yellow
colorbar();

カテゴリ

Help Center および File ExchangePurple についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by