Borrar filtros
Borrar filtros

histogram function, bins and edges

50 visualizaciones (últimos 30 días)
Timo Strotbaum
Timo Strotbaum el 1 de Ag. de 2018
Comentada: Adam Danz el 18 de Abr. de 2023
Hi everybody,
I´m trying to plot some histogramms of different vectors, and therefore i need to determine as well the number of bins as the Edges for the histogramm. when changing either of them, Matlab changes the other one automatically, is there a way i can determine these numbers by myself?
h = histogram(v,"NumBins",100,'Normalization','probability', "BinEdges", [5.4536e+03:1.2093e+05])
I tried to put everything in as input arguments, but the histogramm has different values:
h =
Histogram with properties:
Data: [66001×1 double]
Values: [1×115476 double]
NumBins: 115476
BinEdges: [1×115477 double]
BinWidth: 1
BinLimits: [5.4536e+03 1.2093e+05]
Normalization: 'probability'
FaceColor: 'auto'
EdgeColor: [0 0 0]
  2 comentarios
KSSV
KSSV el 1 de Ag. de 2018
Why do you feel they are different? It is acting accordingly to your input.
Timo Strotbaum
Timo Strotbaum el 1 de Ag. de 2018
Because in said NumBins should be 100, not 115476

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 1 de Ag. de 2018
If you want 100 bins use:
h = histogram(v,"NumBins",100,'Normalization','probability', "BinEdges", linspace(5.4536e+03,1.2093e+05,101)) ;
  1 comentario
Adam Danz
Adam Danz el 18 de Abr. de 2023
In this case, "NumBins" is being ignored. Either use NumBins or BinEdges.
Here's an example where NumBins=2 but there are 100 bins defined by BinEdges.
h = histogram(rand(1,1000), "NumBins", 2, "BinEdges", linspace(0, 1, 101));

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by