I have a Matrix with ones and zeroes. How to plots the matrix with zeroes as black spot and ones as whote dots as shown in figure below.

 채택된 답변

Star Strider
Star Strider 2021년 9월 15일

0 개 추천

Try this —
M = randi([0 1],25)>0; % Logical Matrix
[r,c] = find(M);
figure
scatter(c, r, 75, 'sw', 'filled')
set(gca, 'Color','k', 'YDir','reverse')
axis([0 size(M,1)+1 0 size(M,2)+1])
% axis('equal')
The spy function works for this, however it does not have the ability to fill the markers, so I went with scatter instead.
figure
spy(M,'sw');
set(gca, 'Color','k')
hs.MarkerFaceColor = 'w';
Experiment to get the result you want.
.

추가 답변 (3개)

millercommamatt
millercommamatt 2021년 9월 15일

0 개 추천

FH = figure;
imagesc(yourMatrix);
colormap(FH,[0,0,0;1,1,1]);
the cyclist
the cyclist 2021년 9월 15일

0 개 추천

M = magic(7);
B = M > mean(M);
colormap('gray')
imagesc(B)
axis square
Matt J
Matt J 2021년 9월 15일
편집: Matt J 2021년 9월 15일

0 개 추천

imshow(yourMatrix)

카테고리

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

제품

릴리스

R2021a

질문:

2021년 9월 15일

답변:

2021년 9월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by