# Plot 3D (colormap)

246 views (last 30 days)
Yrobel Lima on 24 Oct 2017
Commented: KSSV on 25 Oct 2017
How can I plot a Matlab function in 3d (X, Y, Z) ?. I used the tri = delaunay (x, y) and h = trisurf (tri, x, y, z) function but I do not use it because it distorts the values. I need to get a color map of the distribution. Thank you very much, I hope you can help me.
Yrobel Lima on 25 Oct 2017
Edited: Walter Roberson on 25 Oct 2017
Thanks, I attached the file with the values.

KSSV on 25 Oct 2017
[num,txt,raw] = xlsread('DATA.xlsx') ;
X = num(:,1) ;
Y = num(:,2) ;
Z = num(:,3) ;
N = 100 ;
x = linspace(min(X),max(X),N) ;
y = linspace(min(Y),max(Y),N) ;
[Xi,Yi] = meshgrid(x,y) ;
Zi = griddata(X,Y,Z,Xi,Yi) ;
surf(Xi,Yi,Zi)
##### 2 CommentsShowHide 1 older comment
KSSV on 25 Oct 2017
Thanking is accepting the answer. :)

Walter Roberson on 25 Oct 2017
F = scatteredInterpolant(x,y,z);
[X,Y] = ndgrid(linspace(-295,295,500),linspace(-510,510,500));
Z = F(X,Y);
surf(X, Y, Z, 'edgecolor', 'none')
##### 1 CommentShowHide None
Yrobel Lima on 25 Oct 2017
Thank you very much, your response was very helpful. 