필터 지우기
필터 지우기

Histogram fraction of total observations and fraction per unit width

조회 수: 22 (최근 30일)
Jacob Smith
Jacob Smith 2022년 1월 19일
댓글: Mohan 2024년 2월 5일
I'm working on a HW problem and I am kind of stuck. I took a class in Matlab several semesters ago and am now in a class where our HW is exclusivly done in Matlab. I've been given a data set where I have to use that data to create a series of histograms. The first histogram is the number of observations over the measuered data, no problem. The second and third histograms ask that I take the given data and display the fraction of total observations over each interval, and display the fraction per unit width over each interval. Is there an easy way to go about doing this or am i going to have to resort to doing the math and creating my graphs?

답변 (1개)

KSSV
KSSV 2022년 1월 19일
You can get the wanted information from histogram.
Example:
x = randn(1,100) ; % random data for demo
h = histogram(x)
h =
Histogram with properties: Data: [-1.3555 0.7552 1.0002 -1.8729 -0.6261 0.4673 -0.4979 -0.5176 1.1454 -1.2476 1.6000 1.2608 0.5668 -0.1758 0.7651 -0.2759 -0.9973 -0.5760 -1.3655 1.2396 -0.5806 0.6480 0.0356 -0.6146 0.3910 -0.4373 -0.6452 1.4512 -0.0810 1.4027 … ] Values: [3 10 20 16 21 14 12 4] NumBins: 8 BinEdges: [-2 -1.5000 -1 -0.5000 0 0.5000 1 1.5000 2] BinWidth: 0.5000 BinLimits: [-2 2] Normalization: 'count' FaceColor: 'auto' EdgeColor: [0 0 0] Show all properties
% fraction of total observations over each interval
h.Values/length(x)
ans = 1×8
0.0300 0.1000 0.2000 0.1600 0.2100 0.1400 0.1200 0.0400
  댓글 수: 3
KSSV
KSSV 2022년 1월 19일
Thanks is accepting/ voting the answer. :)

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

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by