How to plot 3D surface with the given points in excel

Hello,
Does anybody know h ow can we plot 3D surface for points in 3 columns as a vector? I have 3 different 20 by 1 vectors and I want to get 3D plot. Two first are input and next output.
Thanks

 采纳的回答

T = readtable(myexcelfile) ;
x = T.(1) ; y = T.(2) ; z = T.(3) ;
%%structured
xi = unique(x) ; yi = unique(y) ;
[X,Y] = meshgrid(xi,yi) ;
Z = reshape(z,size(X)) ;
figure
surf(X,Y,Z)
%%unstructured
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
figure
trisurf(tri,x,y,z)

7 个评论

Thank you so much. Actually I put x , y, and z in matlab itself as a 8 by 1 vector for each. The code that gives 3 by 3 matrix and it gives error as
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
x = [0.333;
0.333;
0.2727;
0.2727;
0.2727;
0.2;
0.2;
0.2];
y= [525;
550;
500;
525;
550;
500;
525;
550];
z = [866.178;
866.178;
877.209;
877.209;
877.209;
885.272;
885.272;
885.272
];
The second code works actually but I do not know the difference
I have commented in the code. First one is structured grid and second one is unstructured grid.
Yes yes I see. However, what does that mean exactly? this means for my data we cant construct structured one or...?
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
[X,Y] = meshgrid(linspace(x0,x1,10),linspace(y0,y1,10)) ;
Z = griddata(x,y,z,X,Y) ;
surf(X,Y,Z)
I used also this one to make it smooth
f = fit([x y],z,"poly23");
plot(f,[x y],z);
But the issue is for some of the data the vertical axis range is too high? Would you please check it and let me know what can I do?
x = [0.333;
0.333;
0.333;
0.2727;
0.2727;
0.2727;
0.2;
0.2;
0.2];
y= [525;
550;
500;
500;
525;
550;
500;
525;
550];
z1= [-74.6;
-21.788;
-125.444;
-124.603;
-71.143;
-17.073;
-107.754;
-52.662;
2.7513];
f = fit([x y],z,"poly23");
plot(f,[x y],z);
c = jet(20);
colormap(c);
shading interp
By the way in matlab 2022 this function does not wok

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Geographic Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by