regards.
Hana.
HIST3 is intended for creating a histogram over a two-dimensional grid, from 2-D
data. It is exactly the 2-D analog of HIST and HISTC. Don't know what you mean
by, "build a 3D histogram combining the first and second dimensions of the
matrix", but you might also look at BAR3.
Hope this helps.
- Peter Perkins
The MathWorks, Inc.
hope you got the point.
Hana.
> I mean that, for example if we have a(:,:,1)=[1 2 3;3 3 1;3 2 2] and
> a(:,:,2)=[1 2 1;3 3 3;1 1 1],then how can we create a 3D histogram
> that contains the 9
> bins:(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2) and (3,3)?
It appears you may mean that a(:,:,1) contains x coords, and a(:,:,2) contains y
coords. I'm guessing that you want some combination of RESHAPE and either
ACCUMARRAY or HIST3, depending on whether or not you want to make a plot. I
still can't tell what it is you are trying to do.
hope it is clear.
Hana.
try this :
r=image(:,:,1)
g=image(:,:,2)
% pixels must be in a single column
r2=reshape(r,prod(size(r)),1)
g2=reshape(g,prod(size(g)),1)
% now matrix of 2 columns for hist3
rg=[r2, g2]
%hist 10x10 default, choose bins for hist3 as you want
h2rg=hist3(rg)
Thanks.
Hanaa.
Hi,
I have a few n cross 3 matrices whose entries are some specific inter-vector angles ranging from 0 to 180 degrees. I wish to split each column in six 30-degree bins (0-30, 30-60, ...150-180) and wish to plot a frequency distribution profile for each of such matrices. As per as I understand, it may be termed a 4-D histogram where the first three dimensions are the three parameters represented by the three columns of the matrix and the forth one should be a RGB color code specifying the frequency of each 3D-bin (e.g, constituted by X-bin: 30-60, Y-bin: 60-90, Z-bin: 0-30). Any suggestions would be great help.
Do you want a histogram count (frequency), or do you want a color
(which would be a 3 element number by the way, not a single one)? To
me, it seems like you're mixing the concepts.
Since all three axes in this essentially 3D plot already represents three (angular) parameters (e.g, parameter X,Y,Z), its only different colors that can now describe the frequency of each 3D-bin. Like 2D Histograms in matlab, I suppose an array of RGB color codes could be pre-defined here also, each of which will be representing a range of percentage occupancy. e.g, if a bin consists of 10% of the total population it will be represented by blue, 20% by red, 30% by green and like that. Then the function will simply distribute the numbers in as many bins according to the user's choice (e.g, in my specific case, 6 * 6 * 6 = 216 3D-bins ), then count the frequency in each 3D-bin, normalize against the total population and put colors from the color-code array to each of the 3D-bins, appropriate to their percentage occupancy. I hope I am understood this time.