Saturday, 15 February 2014

How to determine the direction of a slope in Matlab? -



How to determine the direction of a slope in Matlab? -

to determine trend of earth, need determine direction of slope using matlab. info point cloud. in area, segment area in windows , each window selects ground point. example, in area of ground points are(x y z):

32512033.4400000 5401401.33000000 346.950000000000 32512044.0300000 5401399.54000000 346.850000000000 32512052.5800000 5401400.37000000 346.760000000000 32512065.0100000 5401401 346.620000000000 32512073.5100000 5401399.99000000 346.480000000000 32512082.6900000 5401400.45000000 346.380000000000 32512094.1000000 5401401.41000000 346.330000000000 32512104.5300000 5401402.62000000 346.120000000000 32512114.5500000 5401401.42000000 345.860000000000 32512116.4800000 5401401.75000000 345.780000000000 32512033.7100000 5401409.82000000 347.120000000000 32512035.3900000 5401410.57000000 347.090000000000 32512052.7300000 5401415.40000000 350.110000000000 32512061.8500000 5401409.82000000 348.740000000000 32512065.8200000 5401415.45000000 359.700000000000 32512079.9800000 5401410.76000000 346.570000000000 32512093.4400000 5401409.58000000 349.620000000000 32512105.0100000 5401409.70000000 346.330000000000 32512114.9800000 5401409.66000000 346.170000000000

i plot surface passes these points , figure here want determine direction of slope, i.e. downwards up... or left right or... how can this?

first question rising is: how did fit thing?

it doesn't seem flat first order fit, if used

sf=fit([x(:),y(:)],z(:),'poly11');

then reply in sf, more particularly in sf.p01 (y direction) , sf.p10 (x direction).

if fitted secret function of yours, can still utilize function diff , average in x , y direction.

%initialization grid corresponding image [xmat,ymat]=ndgrid(-40:40,-60:60); zmat=yourfunction(xmat,ymat); dzdx = diff(zmat,1,1)./diff(xmat,1,1);%x direction dzdy = diff(zmat,1,2)./diff(ymat,1,2);%y direction slopex=mean(dzdx(:)); slopey=mean(dzdy(:));

you might need think little bit if right reply doesn't come straight it. in case (with yourfunction = sf) works perfectly.

cheers

ps: if you're looking normal vector, hence giving direction, can compute way:

%normal vector fitted surface n=-1.*[slopex, slopey, -1]; n=-1.*[slopex, slopey, -1]./sqrt(n*n');

matlab direction trend

No comments:

Post a Comment