function [speed, direction] = UVtoSpDir(u,v);

%UVtoSpDir.m
%
%[speed, direction] = UVtoSpDir(u,v);
%
%Program to convert u and v to speed and direction.

[m,n] = size(u);

speed = repmat(NaN,size(u));
direction = repmat(NaN,size(v));

for i = 1:n;
    for i2 = 1:m;
    speed(i2,i) = sqrt(u(i2,i)^2 + v(i2,i)^2);
    direction(i2,i) = atan2(v(i2,i),u(i2,i))*(180/pi);
    end
end
