Exercise 1

1 Question

Which are the type rules for concatenation?


1.1

The arrays that is concatenated must have the same number of dimensions.
The concatenation dimension k, that you use, must exist.
Arrays must have identical dimension sizes with the exception of the size of dimension k

Argument arrays must have equivalent maximally expanded element types, where the element type of the result array is the element type of the maximally expanded type of the arguments.


2 Considering Array Concatenation

What will be the result of the arrays below?



2.1

2.1.1 array1

array1 has the result {{22, 34, 15}, {66, 78, 52}}


2.1.2 array2

array2 has the result {{22, 34, 15}, {66, 78, 52}}


2.1.3 array3

array3 has the result {{11, 12}, {13, 14}}


2.1.4 array4

array4 has the result {{7, 2}, {5, 42}, {24, 74}}


2.1.5 array5

array5 has the result {{7, 2}, {5, 42}, {24, 74}}


2.1.6 array6

array6 has the result {{1, 2}, {11, 12}, {13, 14}, {3, 4}}


2.1.7 array7

array7 has the result {{1, 2, 35, 73}, {72, 51, 12, 23}}


2.1.8 Simulation of ArrayConcatenation


3 Using cat

Now it is your turn to concatenate arrays using cat:

Concatenate two 1x2-arrays along the first dimension.
Concatenate the arrays you just concatenated, but along the second dimension.
Concatenate one 2x3-array with a 2x1-array along the second dimension.
Concatenate two 2x2-arrays along the first dimension.

What are the results of the array concatenations?



3.1

These are examples of how you could concatenate the arrays in the exercise.



3.1.1 myArray1

myArray1 has the result {{1, 2}, {11, 12}}


3.1.2 myArray2

myArray2 has the result {{1, 2, 11, 12}}


3.1.3 myArray3

myArray3 has the result {{21, 32, 43, 12}, {66, 77, 55, 24}}


3.1.4 myArray4

myArray4 has the result {{10, 40}, {55, 78}, {20, 50}, {31, 22}}


3.1.5 Simulation of MyArrayConcat


4 More Dimensions

The last thing you should do now is to concatenate three arrays with higher dimension.

So, the arrays you should concatenate are of size 1x2x1, 1x2x2 and 1x2x3 and they should be concatenated along the first dimension. Do the concatenation in the class
MoreConcat below.

What is the result after the concatenations?



4.1

This is an example of how you could concatenate the arrays in the exercise.



4.1.1 aReady

aReady has the result {{1, 3, 4, 7, 8, 9}, {2, 5, 6, 10, 11, 12}}


4.1.2 Simulation of MoreConcat