Plot binary matrix as dot

조회 수: 6 (최근 30일)
maoster
maoster 2015년 6월 25일
댓글: the cyclist 2022년 7월 21일
Hi,
I have this matrix that indicates a location [0 0 0 0 1 0 1 1 0 0 1 0 0 0]. I want to plot the value of 1 from this matrix using dot as the marker. How can I do it?
Thanks.
  댓글 수: 1
maxanto
maxanto 2021년 6월 18일
spy([1 1 0; 0 0 0; 1 0 1])

댓글을 달려면 로그인하십시오.

채택된 답변

James Tursa
James Tursa 2015년 6월 25일
Another way:
spy(sparse(x));
  댓글 수: 3
Leyla Elyasizad
Leyla Elyasizad 2022년 7월 18일
Does it work for big matrix?
I used it for a big matrix it seems that it is squeezing the figure
the cyclist
the cyclist 2022년 7월 21일
When you say "squeezing", what do you mean?
My best guess is that perhaps the aspect ratio of the figure is not what you expect? You could do commands like axis square or axis equal, and see if that gives more like what you expect. (There are other options, as well.)

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

maxanto
maxanto 2021년 6월 18일
spy([1 1 0; 0 0 0; 1 0 1])

the cyclist
the cyclist 2015년 6월 25일
편집: the cyclist 2015년 6월 25일

One guess at what you want. If this is not what you want, I suggest you add detailed explanation.

figure
x = [0 0 0 0 1 0 1 1 0 0 1 0 0 0];
x(x==0) = NaN; % Changing the value of x. If you need it preserved, save to a new variable.
h = plot(1:numel(x),x,'k.');
set(h,'MarkerSize',24)
xlim([0.5 numel(x)+0.5])

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by