function [del azm] = delaz(first, second)    % delta and azimuth function
R= 6371;                        % Radius of the earth

nfirst=size(first,2);
nsecond=size(second,2);                  % n is the station number
n=max([nfirst nsecond]);


% n is the number of pairs of points for which we want delta and azimuth
% Matching the matrix sizes - expand the list that is single, and don't have
% to worry about it anymore
if nfirst==1
eq=repmat(eq,1,n);
elseif nsta==1
sta=repmat(sta,1,n);
elsif nfirst==nsecond
break %don't have to do anything, are matched
else
disp('error in input - inconsisten sizes')
return
end

% checking valid range of the input values for earthquake source
%could do this first, before repmats, to not have to test single entry
%multiple times, but have to process eq and stns separately.

%have to break apart into 2 vectors - one for lat and one for lon since 
%can't do the test differently for each column of the original matrix
%test stations and eq together

T=[sta eq];
Tlat=T(1,:)
Tlon=T(2,:)

%set bad data to NaN so get NaN back for answer for that station - if print out names
%will see which ones are bad/NaN.
Tlat(Tlat<-90|Tlat>90)=NaN
Tcolat=(90-(Tlat));
Tlon(Tlon<-180|Tlon>360)=NaN

%make logical matrix with result of test - can use later to select which ones have
%good data, but not too useful for identifying bad inputs.
TestLat=(-90<=Tlat&Tlat<=90)
TestLon=(-180<=Tlon&Tlon<=360)
%code to process this

%find row/col indices of good data to process, this allows one to keep track of the good
sites for printing out, etc., but is more complicated.
[TestLatRow TestLatCol val]=find(-180<=Tlon&Tlon<=360)
[TestLonRow TestLonCol val]=find(-180<=Tlon&Tlon<=360)
%find row/col indices of bad data to flag and not process
[TestLatRow TestLatCol val]=find(~(-180<=Tlon&Tlon<=360))
[TestLonRow TestLonCol val]=find(~(-180<=Tlon&Tlon<=360))

%so far id bad lat and bad lons - NaN method will give NaN for result for
%one or other or both of lat and lon being bad, but does not identify which.
%last method allows identifying bad lats and lons individually for reporting, but is more work upfront

%if use last method can build new dataset of good points to process and
%report bad ones (need to use function sub2ind to get elements to process
and report).
