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]

回答 (1 件)

Sachin Ganjare
Sachin Ganjare 2012 年 10 月 15 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2012 年 10 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by