필터 지우기
필터 지우기

Display the quotient of two histograms

조회 수: 4 (최근 30일)
abc abc
abc abc 2016년 5월 12일
댓글: Walter Roberson 2016년 5월 12일
Hi, i have two histograms of X and Y and what i would like to do this if it is possible :
i would like to display an histogram which will be the quotient of the two histograms. Of course i have the same borders for the two sides.
Any idea ?
Thanks a lot !

답변 (1개)

Walter Roberson
Walter Roberson 2016년 5월 12일
If you are using the newer histogram function, then access the Values properties of the two, calculate the ratios, and use bar() to draw the result.
  댓글 수: 4
abc abc
abc abc 2016년 5월 12일
But the problem is X and Y are matrix but have no the same dimensions so i can't write X./Y. However i think i can do countsX/countsY ?
Walter Roberson
Walter Roberson 2016년 5월 12일
subplot(1,3,1);
h1 = histogram(rand(1,100).^2, 15);
h1_edges = h1.BinEdges;
h1_cents = mean([h1_edges(1:end-1); h1_edges(2:end)]);
subplot(1,3,2);
h2 = histogram(randn(1,100).^2, 15);
ratio = h1.Values ./ h2.Values;
subplot(1,3,3);
bar(h1_cents, ratio);
Make sure they have the same number of bins.
Also, the above is not a great example because the range of the second histogram is wider, so the bins do not align. Or perhaps it is a good example, as it shows the danger of just taking the ratio of the bins instead of making sure that the bins are for the same range.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by