Filter löschen
Filter löschen

Calling variables instead of values

2 Ansichten (letzte 30 Tage)
Will
Will am 31 Okt. 2011
I have this:
A=1; B=2; C=3;
x = [2 3 1]
I want to call x1 as:
x1 =
B C A
I can call individual values, but I don't know how to call them as variables.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 31 Okt. 2011
xc = num2cell(x)
[B C A]= xc{:}
ADD
x = [2 3 1]
xc = {'A' 'B' 'C'}
x1 = xc(x)
  2 Kommentare
Will
Will am 31 Okt. 2011
I don't think that's what I'm looking for.
I need to associate A, B and C to [2 3 1] and output [B C A]
And also, I was using 2 3 1 and B C A as an example. I must take in many more numbers if needed.
Jan
Jan am 31 Okt. 2011
@Will: What does "[B C A]" exactly mean? Is it a cell string, a string or a symbolic expression?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by