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

조회 수: 1 (최근 30일)
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
Brendan Hamm
Brendan Hamm 2016년 1월 15일
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 2016년 1월 15일
Thank you so much, i'm so tired that didn't remember that detail :D

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by