How to use trapz for histogram?

2 visualizaciones (últimos 30 días)
Mah Mhata
Mah Mhata el 15 de Feb. de 2019
Respondida: Star Strider el 15 de Feb. de 2019
I want to compute area under curve, when 2<x<8
how can i use trapz?
Help me please
my code:
a=[1,3,3,2,1,3,8,8,9,0,6,5,15,4,14,3,2,1,2,14]
aa=histogram(a'Normalization','probability')

Respuesta aceptada

Star Strider
Star Strider el 15 de Feb. de 2019
Try this:
a=[1,3,3,2,1,3,8,8,9,0,6,5,15,4,14,3,2,1,2,14];
aa = histogram(a,'Normalization','probability');
edgs = aa.BinEdges;
vals = aa.Values;
ctrs = edgs + mean(diff(edgs))/2;
lidx = (ctrs > 2) & (ctrs < 8);
AUC = trapz(ctrs(lidx), vals(lidx));

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by