Как и в названии, мой общий массив не добавит ни одного из значений, взятых из любого из моих дистанционных массивов, и вернет только 1. Общий массив не будет распознавать любые значения i и, кажется, полностью игнорирует его.Если бы кто-нибудь мог объяснить мне, как я буду получать ошибку 21 в Scilab, используя этот код?
Любая помощь будет оценена за предоставленную мне консультацию.
perms_x = perms(x)
perms_y = perms(y)
lngth = length(x)
fctrl = factorial(lngth)
total = zeros(fctrl) //initializes a zero array using factorial as the number of elements
for i=1:fctrl //loop that goes from 1 to factorial value
for k=1:lngth //loops from the start of the array until the length
distance(k) = sqrt((perms_x(i,k)-perms_x(i, k+1))^2 + (perms_y(i, k+1)-perms_y(i, k+1))^2);
total(i) = distance(k) + sum(i);
end
//adds the value of city 1 to 0
distance_1(i) = sqrt(perms_x(i,1)^2+perms_y(i,1)^2);
//adds the value of city n to 0
distance_n(i) = sqrt(perms_x(i,lngth)^2+perms_y(i,lngth)^2);
//adds both values of city 1 and city n to the current sum
total(i) = total(i) + distance_1(i) + distance_n(i);
end
disp (total)
g=min(total)