MATLAB: Can somebody explain me this answer

matrix

a=[1 2; 3 4]; a(3*ones(2)) ans= 2 2 2 2

Best Answer

The code copies the third element of a as 2 by 2 matrix, see the below example:
>> a
a =
1 2
3 4
>> a(:)
ans =
1
3
2
4
>> a([3,3;3,3])
ans =
2 2
2 2
>>