Extracting part of grid from meshgrid
이전 댓글 표시
I am working with some antarctic DEM data in Matlab. So, far I have been able to generate a nice looking mesh, with the following basic code:
load (Data.xyz)
X = Data(:,1);
Y = Data(:,2);
Z = Data(:,3);
xr = unique(X);
yr = unique(Y);
gz = zeros(length(yr),length(xr));
gz = griddata(X,Y,Z,xr,yr');
figure
mesh(xr,yr,gz);
hold on
contour3(xr,yr,gz,'k-');
hold off
Now I have a few questions, which I have not been able to answer despite being at it since past couple of days and looking at all forums and googling day and night. I hope you all experts might be able to suggest me something. My questions are:
1. The above code takes a lot of time. Agreed that the DEM for antarctica is large sized and slow response time for a code does not necessarily mean that its incorrect. However, I am totally unable to run this code on my laptop (2.5 GHz/4GB) - its so slow. I am wondering if there are other ways to generate mesh which are faster and more efficient.
2. The second issue is that the above "Data.xyz" contains DEM data from all antarctica. After generating a mesh, I want to clip it based on locations. Say, for e.g., I want to extract mesh data for area bound by x1,y1, x2,y2, x3, y3, and x4,y4. How do I go about doing that? I could not find a suitable function or tool or any user script anywhere which will allow me to do so. Is it possible to cut a mesh in matlab?
I am running Matlab 2012a, and I do not have access to mapping toolbox. Any suggestions???
댓글 수: 4
Sara
2014년 6월 27일
Why do you use griddata? is the original DEM missing some values? Have you tried:
profiler on
...your code
profiler off
profiler viewer
to check what is the slowest step?
How big is Data?
For the clipping, do you want a rectangular region or something else?
sumant
2014년 6월 30일
Sara
2014년 6월 30일
Have you tried repmat? if you have nx data repeated ny times (or the other way around), that function will create the 2d array for you without the interpolation step done by griddata.
Chad Greene
2014년 6월 30일
May I ask which data set you're using? If xyz data is scattered it likely needs to be gridded. But it's possible that your data set is already gridded.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!