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

3d matrix array plot

8 views
Skip to first unread message

dong sanchai

unread,
Apr 24, 2008, 8:48:02 AM4/24/08
to
hi,

this might be newbie Q,

i have 3d matrix array, for example size 240x360x40.
i want to plot it into 3D graph. however when i use mesh,
it gives error like this

??? Error using ==> mesh
Z must be a matrix, not a scalar or vector.

??? CData must be an M-by-N matrix or M-by-N-by-3 array.

Error in ==> mesh at 93
hh = graph3d.surfaceplot
(x,'FaceColor',fc,'EdgeColor','flat', ..
----------------------------------------
if i used plot3, the error is :
>> plot3(a, 'x')
??? Error using ==> plot3
Data may not have more than 2 dimensions

size a = 240 360 40

i try to use other plot like surf.
the only plot succes is when i plot 2 dimension of the
data :
example mesh(a(:,:,1));

please help TQ

TQ

the only plot i can make is
Not enough input arguments.

Ethan

unread,
Apr 24, 2008, 9:53:01 AM4/24/08
to
What does the data consist of?

You need to understand what you're plotting before you plot it.
Each element of the 3D matrix, A, has an 3 indices, x,y,z, and a value, A(x,y,z).

What do the indices represent in your data? I.e., what does the position of the
value in the matrix represent?

What does the value itself represent?
Are there dependent and independent variables?

Now decide what you want to plot.

Most likely, you really want to plot multiple 2D planes from your data, eg.
offset=max(A(:));figure; hold on; for i=1:40; surf(A(:,:,i)+offset*(i-1));end
I added an offset so the surfs would be stacked. 40 planes of 240x360 is likely
too much info to visualize all at once.

(For mesh(X,Y,Z) and surf(X,Y,Z) , each of the input matrices represents a
coordinate value. It's like plot3(X(:),Y(:),Z(:),'o') without all the nice graphics.)

Rajendra Gad

unread,
Jul 5, 2010, 6:09:04 AM7/5/10
to
"Ethan " <emontag...@leuzeusa.com> wrote in message <fuq3bt$l9r$1...@fred.mathworks.com>...

Rajendra Gad

unread,
Jul 5, 2010, 6:12:04 AM7/5/10
to
The function
plot3(X(:),Y(:),Z(:),'o') dose not work.
I want to plot the A[1,1,i]
and similarly do it for all elements of x , y dimensions

Regards
Rajendra


"Ethan " <emontag...@leuzeusa.com> wrote in message <fuq3bt$l9r$1...@fred.mathworks.com>...

Rajendra Gad

unread,
Jul 5, 2010, 6:16:04 AM7/5/10
to
The function
plot3(X(:),Y(:),Z(:),'o') dose not work.
I want to plot the A[1,1,i]
and similarly do it for all elements of x , y dimensions

Regards
Rajendra


"Ethan " <emontag...@leuzeusa.com> wrote in message <fuq3bt$l9r$1...@fred.mathworks.com>...

redrocket

unread,
Jul 9, 2013, 3:45:20 PM7/9/13
to
"Rajendra Gad" <rs...@unigoa.ac.in> wrote in message <i0sbd4$be0$1...@fred.mathworks.com>...
How can I replace a 'o' by a vertical bar.

For example I have this matrix

A = [1 2 3 4 5
2 4 6 8 10
1 7 8 0 3];

plot3(A(1,:),A(2,:),A(3,:),'o')

and row 1 col 1 is the x-axis, 2 4 6 8 10 would be the y-axis while row 3 would be the z axis. I have been trying to get a 3d plot for this with vertical bars denoting the row 3 instead of 'o'

Thanks.
0 new messages