Assign characters to numbers in a matrix

if
R=[2,1,3,4]
A=1
B=2
C=3
D=4
How do I make it so that when I type R,,,
It would come out,
R=[B,A,C,D]
???
"use for loop, with elseif statements"
[Merged information from duplicate question]
Hi. I'm just starting to learn matlab and I've been stuck on this question.......
Vector
R=
[0.3902
0.2927
0.2195
0.0732
0.0244]
A=.2927
B=.3902
C=.2195
D=.0244
E=.0732
Now, I'm supposed to create a different vector with the characters, in the same order...but the HINT says "Use a for loop combined with elseif statements."
So the new vector should look like...
R=
[B
A
C
E
D]

Answers (1)

You can build a logic using for loop plus ascii values of characters.
Hope it helps!!

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 15 Oct 2012

Community Treasure Hunt

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

Start Hunting!