Want to plot a matrix as a 3D histogram or bar chart.

조회 수: 20 (최근 30일)
Dean Ranmar
Dean Ranmar 2016년 9월 15일
댓글: Dean Ranmar 2016년 9월 15일
I have a matrix (A) of count values. It counts the number of times event (x,y) occurs during a process, where x & y are integer metrics with pre-defined, non-equal ranges (thus A is not square). That is, every time event (9,10) occurs, the accumulator (counter) array is incremented: A(9,10)=A(9,10)+1. I want to plot out the matrix A as a histogram (or bar chart) to examine and analyze the distribution of events. I am aware of bar3 and some MATLAB histogram plotting scripts but I don't see how to make them work, for this application. (I did search the download section here but didn't find what I want.)
  댓글 수: 1
José-Luis
José-Luis 2016년 9월 15일
Could you show an example of what you want and how exactly bar3() doesn' t work?

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

채택된 답변

Image Analyst
Image Analyst 2016년 9월 15일
With a size of 128 by 1024, you might be better off using surf() than bar3(), or simply viewing it as an image instead of a 2.5-D rendering (a 3-D rendering of your 2-D array onto your 2-D flat screen monitor).

추가 답변 (3개)

Thorsten
Thorsten 2016년 9월 15일
A = rand(9,10); % sample values
bar3(A)
  댓글 수: 1
Dean Ranmar
Dean Ranmar 2016년 9월 15일
Thanks. I've tried this and it doesn't work in my case. When I call bar3, I get a 2D figure for some reason. I tried the specific code lines you suggested, adjusted to my array size (128x1024) and it works. My test case is fairly sparse (few samples) and that may be the problem, I'll try loading the matrix with more values and see if that helps.

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


Steven Lord
Steven Lord 2016년 9월 15일
As of release R2016b, the histogram and histogram2 functions can create a histogram using either raw data to be binned or precomputed bin counts. See the Release Notes for more information.
  댓글 수: 1
Dean Ranmar
Dean Ranmar 2016년 9월 15일
I will have to update then. I'm using 2015b right now. Thanks.

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


Dean Ranmar
Dean Ranmar 2016년 9월 15일
Thank you! I completely forgot about surf. It worked like a charm.

카테고리

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