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. !

To obtain nonunit spacing, specify an increment. For example

 

  10:-2:0   
is
	ans  =

	!   10.    8.    6.    4.    2.    0. !    
Subscript expressions involving colons refer to portions of a matrix.

 

S(1:k,j)
is the first k elements of the jth column of S.
   S(1,1:4)
produces
	ans  =

	!   16.    3.    2.    13. !   
Okay, let's come to the magic square 
Why 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
sum(1:16)/4

which, of course, is

	ans  = 
	   34