Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
3d plot

Subject: 3d plot

From: Paul

Date: 8 Jul, 2011 22:02:10

Message: 1 of 3

Hello,
I am trying to construct a 3d plot from a matrix.

The horizontal axes ranges should be the row and column indices of the matrix, and the vertical axis should be the values in the matrix. I looked at plot3, but it seems the vectors have to be the same lengths (the matrix is not square).

Any thoughts? Thanks!

Subject: 3d plot

From: ImageAnalyst

Date: 8 Jul, 2011 22:05:30

Message: 2 of 3

On Jul 8, 6:02 pm, "Paul " <pale...@hotmail.com> wrote:
> Hello,
> I am trying to construct a 3d plot from a matrix.
>
> The horizontal axes ranges should be the row and column indices of the matrix, and the vertical axis should be the values in the matrix.  I looked at plot3, but it seems the vectors have to be the same lengths (the matrix is not square).
>
> Any thoughts?  Thanks!

---------------------------------------------------
Try surf() to plot the matrix as a surface in a 2.5D perspective-type
plot.

Subject: 3d plot

From: Roger Stafford

Date: 8 Jul, 2011 22:41:10

Message: 3 of 3

"Paul " <palex71@hotmail.com> wrote in message <iv7up1$s5f$1@newscl01ah.mathworks.com>...
> Hello,
> I am trying to construct a 3d plot from a matrix.
>
> The horizontal axes ranges should be the row and column indices of the matrix, and the vertical axis should be the values in the matrix. I looked at plot3, but it seems the vectors have to be the same lengths (the matrix is not square).
>
> Any thoughts? Thanks!
- - - - - - - - - -
  Call your matrix Z.

 [X,Y] = meshgrid(1:size(Z,1),1:size(Z,2));
 plot3(X,Y,Z) % or surf(X,Y,Z)

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us