Frequency distribution of monthly data

조회 수: 18 (최근 30일)
Ancalagon8
Ancalagon8 2023년 1월 17일
편집: Star Strider 2023년 1월 18일
I have a monthly timetable with some values and I need to calculate the frequency distribution in classes from 0 to 10 with step of 0.1. Right now using tabulate I receive these results.
frequency=(0:0.1:10);
tabulate(TT)
Value Count Percent
0 42832 95.95%
0.1 1549 3.47%
0.2 132 0.30%
0.3 48 0.11%
0.4 26 0.06%
0.5 16 0.04%
0.6 11 0.02%
0.7 2 0.00%
0.8 9 0.02%
0.9 4 0.01%
1 4 0.01%
1.1 3 0.01%
1.2 3 0.01%
1.3 1 0.00%
How can I fill the classes until 10 (even with zeros, in other months I expect to have higher values).

답변 (1개)

Star Strider
Star Strider 2023년 1월 17일
The tabulate function does not allow the edges to be specified. The histcounts function does.
Define the edges as:
Ev = linspace(0, 10, 101)
Ev = 1×101
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000
to get 100 bins with the appropriate spacing, or use the NumBins option or the nbins argument.
If you want the frequency (rather than the default 'counts'), choose the 'probability' Normalization option.
.
  댓글 수: 8
Ancalagon8
Ancalagon8 2023년 1월 18일
편집: Ancalagon8 2023년 1월 18일
Thanks again! So the frequency distribution in classes from 0 to 10 with step of 0.1 for every month is stored in Nv? Because Nv is a 44640x1 cell, while I expected a 12x1 one.
Star Strider
Star Strider 2023년 1월 18일
편집: Star Strider 2023년 1월 18일
My pleasure!
Yes. The bins are an array that go from 0 rainfall to the maximum rainfall (‘ceil(Rainmax)’ so 5 here) in the entire timetable. The limits can be anything that works, so 10 is also an acceptable option for the upper limit of ‘Edges’. I chose the upper limit here to increase the resolution so the individual bars would be easier to see.
Also, the ‘Binv’ cell array stores the bin indices (in this instance, indices into the the dates and times for each month) that contributed to each bin. I don’t know if that’s important, however the histcounts function produces it, so I returned it and saved it.
EDIT — (18 Jan 2023 at 21:57)
When I re-ran my code just now and viewed it,, ‘Nv’ is a (12x1) cell array.
.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by