I have the following test code with an error thrown when trying to populate array C using the degrees2dms function:
% Array with original DMS (n x 3 array)
A = [180 342 350 121 125 179; 0 54 41 16 23 59; 3 49 18 20 13 50]'% Array for Degrees.Decimal values (from array A)
B (6,1) = zeros% Array for degrees2DMS repopulation
C (6,3) = zeros%% Initial dms2degrees Array B Population
for i = 1:6 B(i,1) = dms2degrees([A(i,1), A(i,2), A(i,3)]) end%% Subsequent degrees2dms Array C Population Attempt
for i = 1:6 degrees2dms([C(i,1),C(i,2),C(i,3)]) = B(i,1) % Error Returned:
% Array indices must be positive integers or logical values.
%Error in Test2_Degrees2dms (line 31)
%degrees2dms([C(i,1),C(i,2),C(i,3)]) = B(i,1)
end
Why am I getting an error stating that negative indicies are being used when I have specified the numberic doman from 1 to 6?
Best Answer