## Plotting 3D for three independent variables without any function

### Yaser Khojah (view profile)

on 21 Mar 2019
Latest activity Commented on by Walter Roberson

on 21 Mar 2019

### Walter Roberson (view profile)

I have four vectors as attached in Data_1.tx. file. I'm looking for a way to plot their surface map. Where X = (:,column3), Y = (:,column 2) and Z = (:,Column 1). I have looked into meshgrid but did not work since I do not have a function to estimate Z from given X and Y Values. They are only data. I have found and tried this below code but did not like the graph.
trisurf(delaunay(X,Y),X,Y,Z)
I have tried Scatter 3 as below and I do not like it. Is there anyway to present them as the below colourful box? Thank you for your help.

### Walter Roberson (view profile)

on 21 Mar 2019
Edited by Walter Roberson

### Walter Roberson (view profile)

on 21 Mar 2019

For a typical surface map, you would use
interpolated_z = griddata(X, Y, Z, query_x, query_y);
surf(query_x, query_y, interpolated_z, 'edgecolor', 'none')
However, the example diagram you give is an example of using https://www.mathworks.com/help/matlab/ref/slice.html on a 3D grid of data. You do not have the information necessary for that -- not unless the unused 4th column of your input is value information.
When I look at your data, it looks to me to be more likely that your first column is value information and that your remaining three columns are X, Y, Z coordinates, rather than your first column being Z coordinates.

Walter Roberson

### Walter Roberson (view profile)

on 21 Mar 2019
V = T{:,1};
X = T{:,2};
Y = T{:,3};
Z = T{:,4};
[query_x, query_y, query_z] = meshgrid(linspace(min(X), max(X),50), linspace(min(Y), max(Y), 50), linspace(min(Z), max(Z), 50));
F = scatteredInterpolant(X, Y, Z, V);
interpV = F(query_x, query_y, query_z);
slice(query_x, query_y, query_z, interpV, [-50], [10], [10])
... but it will not look very useful.
I suggest that you use
volumeviewer(interpV)
and play around with the settings. Have a look at isosurface and MRI settings perhaps. It is not easy to get useful information out of it.
Yaser Khojah

### Yaser Khojah (view profile)

on 21 Mar 2019
Thank you so much, this is really useful. Is V presented by the colorbar?
Walter Roberson

### Walter Roberson (view profile)

on 21 Mar 2019
Yes, V is represented as color.
You can also create a diagonal set of query points, and hold on and slice() with it. When I looked at the data I could not see any particular angle that it would make sense to slice at.