Matlab recommends to replace histc by histcounts. However, I obtain different results:
x=[123.1900 120.9395 120.9395 120.9395 112.6711 415.4625];
y=[112.6711 120.9395 123.1900 415.4625]
which yields
K>> histc(xRd(:),auxVecX)
ans =
1
3
1
1
but
histcounts(xRd(:),auxVecX)
ans =
1 3 2
How can I handle histcounts so that the outputs are the same?

1 comentario

Gunther Schaaf
Gunther Schaaf el 12 de En. de 2022
Sorry, I meant histc(x,y) versus histcounts(x,y).

Iniciar sesión para comentar.

 Respuesta aceptada

Bruno Luong
Bruno Luong el 12 de En. de 2022

1 voto

The result differ by the way the last bin is handed in both function. To get the same result you must change the last edge to Inf for histc
x=[123.1900 120.9395 120.9395 120.9395 112.6711 415.4625];
y=[112.6711 120.9395 123.1900 415.4625];
xRd = x;
auxVecX = y;
auxVecX(end) = Inf
auxVecX = 1×4
112.6711 120.9395 123.1900 Inf
histc(xRd(:),auxVecX)
ans = 4×1
1 3 2 0

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Etiquetas

Preguntada:

el 12 de En. de 2022

Respondida:

el 12 de En. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by