# How to find the area under part of the histogram

7 vues (au cours des 30 derniers jours)
Joy Shen le 11 Mar 2022
Réponse apportée : Paul le 11 Mar 2022
Hi, I'm trying to find the area under part of a histogram? I'm aware that this gives me the total area under the histogram:
area = sum(h.Values)*h.BinWidth;
But I'm trying to find up to a certin edge, for example I want to find the area under the curve from bin edge 3 to bin edge 5. I know I'd have to take the difference to find that area between 3 and 5
Here's my code:
n = 1000000;
%Flow Area Lognormal Prior Assumption
lambda = 1; %Lognormal mean
zeta = 0.2; %Lognormal standard deviation - Subject to change!!! No justification yet
fa = lognrnd(lambda, zeta,n,1);
edges = [0 3 7 15 50];
figure
h = histogram(fa,'Normalization','pdf');
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Paul le 11 Mar 2022
Replace sum() with cumsum() and then subtract to get the area between two bins of interest?
doc cumsum
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Histograms dans Help Center et File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by