matlab - Meshgrid / Surface clipping -


i working antarctic dem data in matlab. so, far have been able generate nice looking mesh, 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 have few questions, have not been able answer despite being @ since past couple of days , looking @ forums , googling day , night. hope experts might able suggest me something. questions are:

  1. the above code takes lot of time. agreed dem antarctica large sized , slow response time code not mean incorrect. however, totally unable run code on laptop (2.5 ghz/4gb) - slow. wondering if there other ways generate mesh faster , more efficient.

  2. the second issue above "data.xyz" contains dem data antarctica. after generating mesh, want clip based on locations. say, e.g., want extract mesh data area bound x1,y1, x2,y2, x3, y3, , x4,y4. how go doing that? not find suitable function or tool or user script anywhere allow me so. possible cut mesh in matlab?

i running matlab 2012a, , not have access mapping toolbox. suggestions???

1.i'd clarify want code do. data x,y,z, assume these points (x,y) (not sampled on grid) each associated elevation z.

when call

gz = griddata(x,y,z,xr,yr'); 

you saying every possible pair (xr(i),yr(j)) locations on grid want sample surface create mesh. wrong don't think want? think rather sample @ equally spaced points, instead using like...

xr = min(x):spacing:max(x); yr = min(y):spacing:max(y);    gz = griddata(x,y,z,xr,yr');  % ' transpose mesh(xr,yr,gz); 

where spacing reasonable number scale of data. way code now, taking far more samples want, why code takes long.

for 2. think for loop add points insde region of interest 3 new lists of x,y,z values. if region rectangular bounded x_left,x_right , y_left,y_right ...

xnew = []; ynew = []; znew = []; = 1:length(x)   if ( x_left<x(i) )&&( x(i)<x_right )&&( y_left<y(i) )&&( y(i)<y_right )     xew = [xnew, x(i)];     ynew = [ynew, y(i)];     znew = [znew, z(i)];   end end 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -