Filter löschen
Filter löschen

assigning text from values

2 Ansichten (letzte 30 Tage)
Bernard
Bernard am 3 Jan. 2014
Bearbeitet: Andrei Bobrov am 3 Jan. 2014
Hello, what is the easiest way to assign a name(kind of like a categorical title) to a value, in a set of values. say 0 = yes, 1 = no, 2 =maybe, 3 = abstain, and I have a vector of the values e.g. X = [0,2,3,2,1,3,2,1,0]. I want to be able to then have a corresponding text vector and then if possible concatenate them so that the text appears in column next to value

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 3 Jan. 2014
Bearbeitet: Andrei Bobrov am 3 Jan. 2014
t = {'yes', 'no', 'maybe', 'abstain'};
X = [0,2,3,2,1,3,2,1,0];
out = [num2cell(X);t(X+1)];

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming 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