I have two arrays, x and y. x is the input of the function and y is the function values.
For example, x = [ 1 2 3 4
I think that you just want:
y(z);
This will return the z'th elements of the y vector. You may want
y(x(z));
Which will return the same result in your example, since x is just the value 1 through 10.
With both of these z can contain only positive integers, and in the second case x must also contain only positive integers.