how to plot a histogram of repeated values in a matrix?

6 visualizaciones (últimos 30 días)
Niki
Niki el 16 de Sept. de 2015
Comentada: Thorsten el 16 de Sept. de 2015
I have a matrix like below.
X = [120 2 3 250 60; 4 5 6 120 250; 7 8 3 250 10]
I want to plot a histogram shows the number of times a value is repated in each columns for example in first 120 in repeated 2 times in this matrix 250 is repeated 3 times in this matrix. any solution ?

Respuesta aceptada

Thorsten
Thorsten el 16 de Sept. de 2015
Editada: Thorsten el 16 de Sept. de 2015
This computes how often each value occurs
[a b c] = unique(X);
[X(b) histc(c, 1:max(c))]
  2 comentarios
Niki
Niki el 16 de Sept. de 2015
Editada: Niki el 16 de Sept. de 2015
but my main question is to plot it not to print it.
Thorsten
Thorsten el 16 de Sept. de 2015
I see. Try this:
B = [X(b) histc(c, 1:max(c))];
stem(B(:,2), 'Linewidth', 2, 'Marker', 'none')
set(gca, 'XTickLabel', B(:,1))
axis([0 size(B,1)+1 0 1.1*max(B(:,2))])
box off

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by