I am trying to call a function that will take two sets of lat lon coordinates and calcuate the distance between them in km. The function latlondist.m itself works for single sets of coordinates, but I am having trouble getting this function to perform iteratively. I have two sets of variables that are used by the function latlondist.m that are both two column doubles, latlon1 and latlon6. I would like my for loop output to be one column containing the distances between the lat lon coordinates in their corresponding rows. For example, for the first row of latlon1 and latlon6 I would like it to execute the function and put the result in the first row of dkm_fwbrev then proceed to second row of both latlon1 and latlon6 and put the output in the second row of dkm_fwbrev, and so on.
Here is the function:
a=sin((deltaLat)/2)^2 + cos(lat1)*cos(lat2) * sin(deltaLon/2)^2;
Here is what I have so far:
if eventID_1 == eventID_6
latlon1 = [lon_1 lat_1];
latlon6 = [lon_6 lat_6];
dkm_fwbrev = zeros(length(lon_1),1);
for index_fwbrev = 1:length(dkm_fwbrev)
The error that this returns is Index exceeds matrix dimensions. Any help would be appreciated.