


calculate slope and aspect (rad) using GRADIENT function USAGE: [grad,asp] = fastder_rad(dem,X,Y) Note: 0 is facing North


0001 function [grad,asp] = fastder_rad(dem,X,Y) 0002 % calculate slope and aspect (rad) using GRADIENT function 0003 % USAGE: [grad,asp] = fastder_rad(dem,X,Y) 0004 % Note: 0 is facing North 0005 dx=abs(X(2)-X(1)); % get cell spacing in x and y direction 0006 dy=abs(Y(2)-Y(1)); % from coordinate vectors 0007 [fx,fy] = gradient(dem,dx,dy); % uses simple, unweighted gradient of immediate neighbours 0008 [asp,grad]=cart2pol(fy,fx); % convert to carthesian coordinates 0009 grad=atan(grad); %steepest slope 0010 %asp(asp<pi)=asp(asp<pi)+(pi/2); 0011 %asp(asp<0)=asp(asp<0)+(2*pi);