Arrays

1 Declaring Arrays

An array is a collection of variables, which are all of the same type. An array variable can be declared by appending dimensions within square brackets after a class name or after a variable name.




Using the alternative syntax of attaching dimensions after the variable name, the same declarations can be expressed as:



2 Multiplication Operator

The multiplication operator * is scalar product when used between vectors, matrix multiplication when used between matrices and element-wise multiplication when used between an array and a scalar. In the function ElementWiseMultiplication positionvector is multiplied by the scalar 2.



3 Calling ElementWiseMultiplication

We see that when applying the function ElementWiseMultiplication on positionvector, we get the result {2, 4, 6}.



4 Matrix Declaration

The common special cases of concatenation along the first and second dimensions are supported through the special syntax forms [A;B;C;...] and [A,B,C,...] respectively. Both of these forms can be mixed. Scalar and vector arguments to these special operators are promoted to become matrices before performing the concatenation. This gives the effect that a matrix can be constructed from scalar expressions by separating rows by semicolon and columns by comma.