I have an array x:
x = [2, 1, 2, 3, 3, 2]
I also have a cell array y:
y = {'alpha', 'beta', 'gamma'}
In fact, x
is a list of indices, where each indicates an element in y
. I now want to create another cell array z
, where each index in x
is replaced with the corresponding element in y
, to give the following:
z = {'beta', 'alpha', 'beta', 'gamma', 'gamma', 'beta'}
How do I do this?