How do I create a 3D histogram for; x = 1*26, y=1*28, z = 26*28 ?

66 views (last 30 days)
I would basically like to bin the the 'z' data into ranges of x and y such as the attached picture:
  2 Comments
Aaron Rampersad
Aaron Rampersad on 22 Mar 2016
I used this code from filexchange but I ended up with a very dense plot attached below:
What I would like to do is place these z-values which is a 26*28 matrix into bins associated with the x and y values

Sign in to comment.

Answers (3)

Walter Roberson
Walter Roberson on 21 Mar 2016
There are also a lot of histogram programs in the File Exchange.

Image Analyst
Image Analyst on 22 Mar 2016
Aaron, give the x and y data as an N by 2 array, then pass in the number of bins in each direction into the poorly named hist3() to create your 2D histogram
counts = hist3([x, y], [26, 28]);
  8 Comments
Image Analyst
Image Analyst on 26 Mar 2016
Well now you'r totally confusing everybody. We though that the x and y were basically ranges that your data could take. So one data point had both an x coordinate, and a y coordinate. And you wanted 28 bins along the y direction, and 26 bins along the x direction. And then "z" would be the counts of how many data points fell into a certain x,y bins. You don't have any z data yet, before taking the histogram, do you? It's to be computed and is the "count" data. If that's not right, then no one has read your mind correctly, and you'll need to explain better and attach your x, y, and z arrays.

Sign in to comment.


Mike Garrity
Mike Garrity on 22 Mar 2016
If you're using R2015b or later, you can use the new histogram2 function.
histogram2(10+5*randn(1e4,1),3*randn(1e4,1),'FaceColor','flat')
  13 Comments

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!

Translated by