Code for frequency of a number of bins
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I need to store into a variable the number of years (frequency) in which a certain number of incidents occured.
The code of the histogram plotted is below. Bin_centres is max/min values of freq(:,2), freq is the array. Column 1 are the years and column 2 are # of incidents.
I think I have to use hist.values and hist.BinEdges, but I don't know how to make that into a working code. I keep getting errors.
hist = histogram (freq(:,2), bin_centres)
2 Commenti
Walter Roberson
il 5 Feb 2023
Bin_centres is max/min values of freq(:,2)
That would lead to only one bin.
Walter Roberson
il 6 Feb 2023
"Bin_centres is max/min values of freq(:,2),"
freq(:, 2) is a vector. It has a single max and a single min. So you only have 1+1=2 bin boundaries. histogram puts data exactly equal to the last value into the previous bin so N edges results in (N-1) bins. 2 edges therefore creates exactly one bin. The result would be to count all of the values between the min and max, inclusive, which of course would just be the same as counting the non-nan inputs.
Risposte (1)
Sulaymon Eshkabilov
il 6 Feb 2023
This is how you can plot hist() or histogram(), e.g.:
D = round(100*(randn(1000, 1)),0)+375;
figure
hist(D, max(D))
figure
histogram(D, min(D))
figure
histfit(D, max(D))
Vedere anche
Categorie
Scopri di più su Histograms in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!