Hi all,
I don't know how to make sure index i not exceed the array bound in this case (since lats is a 9×13 matrix, NumCenPts is actually the matrix's number of columns and depends on the situation number of rounds can be larger then number of columns and vice versa). need_to_modify_code.m is attached below
NumCenPts = 13;load('need_to_modify_code');V=10;for i=1:length(lats)-1 for j=1:NumCenPts %------------------------------------------------------
%Defining arcs and cost for going straight
%------------------------------------------------------ arcStraight(i,j)=distance('rh',lats(i,j), lons(i,j),lats(i+1,j),lons(i+1,j),referenceEllipsoid(7030)); %Defining arcs and cost for going right
%------------------------------------------------------ if j<NumCenPts arcRight(i,j)=distance('rh',lats(i,j),lons(i,j), lats(i+1,j+1),lons(i+1,j+1),referenceEllipsoid(7030)); end %-------------------------------------------------------
%Defining arcs and costs for going left
%------------------------------------------------------ if j>1 arcLeft(i,j)=distance('rh',lats(i,j),lons(i,j), lats(i+1,j-1),lons(i+1,j-1),referenceEllipsoid(7030)); end endend
Thank you for your time,
Sincerely,
Best Answer