function [delangle]=angle1minus2(angle1,angle2)
% computes the difference between two angles
% returns the smallest magnitude value
n=max(size(angle1));
delangle=0*angle1;
for i=1:n
onetest=wrapTo2Pi(angle1(i));
twotest=wrapTo2Pi(angle2(i));
del1=onetest-twotest;    
del2=onetest-twotest+2*pi;
del3=onetest-twotest-2*pi;
testv1=abs(del1);
testv2=abs(del2);
testv3=abs(del3);
testv4=min([testv1 testv2 testv3]);
if testv1==testv4, delangle(i)=del1; end
if testv2==testv4, delangle(i)=del2; end
if testv3==testv4, delangle(i)=del3; end
end
