MATLAB: What do brackets mean in this expression, y(Z)

parenthesis

>>%Hi:
>>y = [1; 2; 3; 1; 2; 3; 1; 2; 3];
>>Z=[1 1 2; 2 1 1; 1 1 4];
>>y(Z)
ans =
1 1 2
2 1 1
1 1 1
>>%But I have no idea what the () operation is. I see it in some code that I'm trying to figure out. Thanks.
>>Wallace

Best Answer

In this case Z is being used to reference the y array. Since Z is also an array, for each value of Z the y array will be referenced and will return the corresponding value in y. Therefore, the result of this command will also be an array the size of Z
i.e. the first row of your Z array is 1 1 2 So when used in the following command MATLAB is actually returning y(1),y(1),y(2) for your first row of data