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
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)));
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Contour Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!