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.

 Respuesta aceptada

James Tursa
James Tursa el 25 de Jun. de 2015

4 votos

Another way:
spy(sparse(x));

3 comentarios

the cyclist
the cyclist el 25 de Jun. de 2015
Makes my code look so bloated! I always forget about spy.
Leyla Elyasizad
Leyla Elyasizad el 18 de Jul. de 2022
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 el 21 de Jul. de 2022
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.)

Iniciar sesión para comentar.

Más respuestas (2)

maxanto
maxanto el 18 de Jun. de 2021

1 voto

spy([1 1 0; 0 0 0; 1 0 1])
the cyclist
the cyclist el 25 de Jun. de 2015
Editada: the cyclist el 25 de Jun. de 2015

0 votos

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])

Categorías

Etiquetas

Preguntada:

el 25 de Jun. de 2015

Comentada:

el 21 de Jul. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by