Plotting 3D for three independent variables without any function

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. scatter.png

5 commentaires

I would like to plot the surface for 3 coulmns. I have plotted the points with the help of scatter3 commands. But I cannot plot the surface. Please could you tell me whichoption will be better for this data.
I would like to have something like this form the above raw data.
Please post the data as a readable file.
Please find the attached data file
t = readtable('Surface plot.xlsx');
x = t.Temp; y= t.Pressure; z = t.Time;
tri = delaunay(x,y);
trimesh(tri, x, y, z);
Thank you so much Mr Walter. It worked for me.

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 21 Mar 2019
Modifié(e) : Walter Roberson le 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.

6 commentaires

Yaser Khojah
Yaser Khojah le 21 Mar 2019
Modifié(e) : Yaser Khojah le 21 Mar 2019
Thanks for your response. Is there anyway kindly you show how would you apply them on my data? I have tried them but did not get them. Feel free to use any values you like. I'm just trying to find any correlation between these vectors. Please note that I do not have any function to create the meshgrid. I only have the data and I do not know how to use meshgrid here.
If I want to use this
interpolated_z = griddata(X, Y, Z, query_x, query_y);
surf(query_x, query_y, interpolated_z, 'edgecolor', 'none')
What is the query_x and y?
[query_x, query_y] = meshgrid(linspace(min(X), max(X)), linspace(min(Y), max(Y));
Dear Walter Thank you so much for this. One more thing please, how would you use slice here and I would go with the remaining three columns are X, Y, Z coordinates and column one as my v in. I'm not sure how I would calcualte the v value here since I do not have a function.
slice(X,Y,Z,V,xslice,yslice,zslice)
I have tried this bud it did not work?
X = MaT_All(idx_Pos,17); % column 2
Y = MaT_All(idx_Pos,18); % column 3
Z = MaT_All(idx_Pos,19); % column 4
V = MaT_All(idx_Pos,16); % column 1
[X1,Y1,Z1] = meshgrid(0:5:60);
[query_x, query_y, query_z] = meshgrid(linspace(min(X), max(X)), linspace(min(Y), max(Y)), linspace(min(Z), max(Z)));
interpolated_v = griddata(X, Y, Z, V, query_x, query_y , query_z);
slice(X,Y,Z,V)
T = readtable('Data_1.txt');
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.
Thank you so much, this is really useful. Is V presented by the colorbar? slic.png
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.

Connectez-vous pour commenter.

Plus de réponses (1)

M Naeem
M Naeem le 23 Juil 2021
can you please help in plotting graph of f(x,y,z)=2x+5xy+11xyz+2z

2 commentaires

N = 50;
xvec = linspace(-5,5,N);
yvec = linspace(-5,5,N);
zvec = linspace(-5,5,N);
[X,Y,Z] = meshgrid(xvec, yvec, zvec);
fxyz = 2 .* X + 5 .* X .* Y + 11 .* X .* Y .* Z + 2 .* Z;
minf = min(fxyz(:));
maxf = max(fxyz(:));
levels = linspace(minf, maxf, 9);
levels = levels(2:end-1);
nlev = length(levels);
for K = 1:nlev
L = levels(K);
isosurface(X, Y, Z, fxyz, L, fxyz);;
end
camlight; lighting phong
legend( string(levels) );
colorbar
hold off
Thank you soo much ...

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by