# 3D plot on 3D matrix

3 views (last 30 days)
Commented: KSSV on 30 Jul 2020
Hi guys, suppose I have a 3D array which look like this. How do I do the plotting with these data?

Matt J on 29 Jul 2020
Plot of what versus what?
X having the values of 1:5:50, Y is the column, and Z

KSSV on 29 Jul 2020
Edited: KSSV on 29 Jul 2020
You can use pcolor/ surf. You can plot w.r.t indices.
val = rand(10,5,2) ;
% using pcolor
subplot(211)
pcolor(val(:,:,1))
colorbar
subplot(212)
pcolor(val(:,:,2))
colorbar
% using surf
subplot(211)
surf(val(:,:,1))
colorbar
subplot(212)
surf(val(:,:,2))
colorbar

Walter Roberson on 29 Jul 2020
Sorry, I do not understand what you are asking... too many "index".
Are you saying that the first column of val() gives the y values?
What kind of plot are you hoping for? When you have three independent dimensions (row, column, pane) and one dependent dimension (the content of val), then you need a 4D plot. You could use isosurface() or slice() or you could use volumeViewer() or any similar routine in which the content of each 3D location is given by color and you cannot see "inside" unless transparency is used.
Im hoping to plot a graph with the x-axis from x=1:5:50 and the y-axis data would change depending on the z index, val(:,:,z).
KSSV on 30 Jul 2020
x = 1:5:50 ;
y = 1:size(val,2) ; % define your y here
[X,Y] = meshgrid(x,y) ;
surf(X,Y,val(:,:,1)') ;