Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating a 3D histogram

36 views
Skip to first unread message

Preet Desai

unread,
Jan 25, 2008, 3:50:19 PM1/25/08
to
Hey!

I need to create a 3D histogram using the mesh function.

I have data from an experiment where coordinates in X and Y
are recorded from an origin. I want the 'Z' value to
indicate the frequency (how many times that particular X
and Y coordinate is the same).

I have this information in a matrix in three columns.

I tried using the mesh function directly on the matrix, but
the graph I got is not right. Even the axes don't
corrospond to the range of the values in the columns in the
matrix.

To reiterate... if this was a 2D plot, I'd be looking at
the coordinates of an XY plot from "above". I want the Z
axis to indicate the frequency for each coordinate.

Would appreciate any help...

Thanks,
Preet

Peter Perkins

unread,
Jan 25, 2008, 5:29:27 PM1/25/08
to
Preet Desai wrote:
> Hey!
>
> I need to create a 3D histogram using the mesh function.

Preet, if it helps at all, the Statistics Toolbox has the HIST3 function
that creates 3D histograms.

Preet Desai

unread,
Jan 25, 2008, 5:37:02 PM1/25/08
to
Peter Perkins <Peter.Perki...@mathworks.com> wrote
in message <fndns7$o3k$2...@fred.mathworks.com>...

With HIST3 I can only specify a matrix with 2 columns...
that means I can't input the frequency data.

Preet Desai

unread,
Jan 25, 2008, 10:45:05 PM1/25/08
to
I think I'm getting closer to what I need to do...
I made a 2D matrix with all the frequency information I
need...and the mesh function works fine for this.

But I need to offset my axes and I don't know how...

for example, take the following 2d matrix:

0 0 0 0 0
0 0 2 0 0
0 1 1 0 0
0 0 0 0 0
0 0 0 0 0

When it's plotted, the graph X and Y axes are like follows:

X: 0 1 2 3 4
-------------
Y: 0| 0 0 0 0 0
1| 0 0 2 0 0
2| 0 1 1 0 0
3| 0 0 0 0 0
4| 0 0 0 0 0

But I need my axes to be like this:

X: -2-1 0 1 2
-------------
Y: -2| 0 0 0 0 0
-1| 0 0 2 0 0
0| 0 1 1 0 0
1| 0 0 0 0 0
2| 0 0 0 0 0

I'm so close to getting my plot perfect!
Any ideas?

Thanks,
Preet


0 new messages