How can I plot contour from excel data points? and make a surface? My code is not working

1 Ansicht (letzte 30 Tage)
Z values on the file are just an example
%%% The code...
if true
% code
end
dmap = xlsread('Base.xls');
% Surface
plot3(dmap(:,1),dmap(:,2),dmap(:,3),'o');
hold on
tri=delaunay(dmap(:,1),dmap(:,2));
trisurf(tri,dmap(:,1),dmap(:,2),dmap(:,3))
% Grids
rangeY=floor(min(dmap(:,2))):.2:ceil(max(dmap(:,2)));
rangeX=floor(min(dmap(:,1))):.2:ceil(max(dmap(:,1)));
[X,Y]=meshgrid(rangeX,rangeY);
Z=griddata(dmap(:,1),dmap(:,2),dmap(:,3),X,Y,'cubic');
surf(X,Y,Z)
rangeZ=floor(min(dmap(:,3))):10:ceil(max(dmap(:,3)));
[C,h]=contour(X,Y,Z,rangeZ);
c_h=clabel(C,h,rangeZ(1:2:end));
surf(X,Y,Z,'EdgeColor','none','FaceColor','interp','FaceLighting','phong')
contour3(X,Y,Z,rangeZ,'k')
  2 Kommentare
Brendan Hamm
Brendan Hamm am 15 Jan. 2016
Just having run this I assume the issue you are getting is due to the fact that you are running out of memory. Your result of rangeX is a 14219 element vector and rangeY is a 140626 element vector, so when you use meshgrid you are trying to create a massive matrix. If you are comfortable with changeing the stepsize then you should get something more reasonably sized:
rangeY=floor(min(dmap(:,2))):200:ceil(max(dmap(:,2)));
rangeX=floor(min(dmap(:,1))):200:ceil(max(dmap(:,1)));
Maria Aparício
Maria Aparício am 15 Jan. 2016
Thank you so much, i'm so tired that didn't remember that detail :D

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by