MATLAB: Calling variables instead of values

matrix manipulation

I had previously asked this: http://www.mathworks.com/matlabcentral/answers/19875-calling-variables-instead-of-values And marked as answered, but I have a little hiccup.
I have this:
A=6; B=7; C=5;
x = [7 5 6]
I want to call x1 as:
x1 =
B C A
Previous answered:
x = [2 3 1]
xc = {'A' 'B' 'C'}
x1 = xc(x)
This line of code only works for values that are within the number of columns of the matrix.

Best Answer

In the previous question you have a single set (x) that has several elements that you want to link to.
In the new problem, you do not have a single set, so you have a way to search each of the possible solutions. There is no easy way to do this. The two ways I know how to do this is with if/else tree (messy), or an enumerator and switch/case setup (not as messy).
if/else tree example
for i = 1:3
if(x(i) == A)
x1(i) = 'A';
elseif( x(i) == B)
...
...
end
end
The other option is using enumeration and switch/case. I've only used enumeration in older versions, so the following is a quick setup for 2009 A.
classdeff my_letters (Enumeration) < int32
proerties
A = 6;
B = 7;
C = 8;
end
methods (static)
function str = string(input)
switch int32(input)
case my_letter.A
str = 'A';
...
...
...
end
end
Now you can use a switch case as opposed to an if-else tree
Switch x(i)
case int32(my_letters.A)
X1(i) = my_letters.A.string();
...
...
end
The switch/Case is cleaner and faster code wise.