필터 지우기
필터 지우기

How do I create a histogram with y axis being count, and x-axis being 20 different possible values?

조회 수: 1 (최근 30일)
Hello,
I have a 76x76 matrix that I would like to convert into a histogram. All the values in it range from -1 to 1, but I only want to use the top triangle values, triu(A,1).
so I would like 21 beams on X-axis ranging from -1,-0.9,-0.8...,0.8,0.9,1.0. The Y-axis will be the amount of entries in the matrix that fit in that particular beam, e.g. 0.62 and 0.60 would both be in the 0.6 beam.
Thank you very much.

채택된 답변

Image Analyst
Image Analyst 2016년 8월 24일
I assume you tried the really obvious route -- the histogram() function. So you'll have to let us know why this isn't working for you.
upperTriangle = logical(triu(ones(size(A)), 1));
edges = -1 : 0.1 : 1;
histogram(A(upperTriangle), edges);
grid on;
xlabel('Value');
ylabel('Count');
Why doesn't this work? It seems simple enough, and seems like it should work.
  댓글 수: 6
Image Analyst
Image Analyst 2016년 8월 25일
Plus, you can't call your function histogram(). There is already a function called histogram(), and you just destroyed it. So now your histogram() function calls itself recursively - NOT what you want.
Lakyn
Lakyn 2016년 8월 25일
thank you! I totally forgot about that. I will try 'em out right away.

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

추가 답변 (0개)

카테고리

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