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 Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by