The Colon Operator
The colon, :
, is one of SCILAB's most important operators. It
occurs in several different forms. The expression,
1:10
is the row vector containing the integers from 1 to 10
ans =
! 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. !
10:-2:0
is
ans = ! 10. 8. 6. 4. 2. 0. !Subscript expressions involving colons refer to portions of a matrix.
k
elements of the j
th
column of S.
S(1,1:4)
produces
ans = ! 16. 3. 2. 13. !
Okay, let's come to the magic squareWhy is the magic sum for a 4-by-4 square equal to 34? If the integers from 1 to 16 are sorted into four groups with equal sums, that sum must be
which, of course, is
ans =
34