Replacing text with value

1 次查看(过去 30 天)
Desmond Chang
Desmond Chang 2022-1-23
评论: Voss 2022-1-23
I have a matrix of A1= [ A B C D E F G H I J K L M N O] and another matrix of value but its quite long so let's say it's A2= [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]. If I have a result of r=[ A E] or r=[ B D L], how do i replace the the letters with its corresponding value?

采纳的回答

Voss
Voss 2022-1-23
A1 = 'A':'O'
A1 = 'ABCDEFGHIJKLMNO'
A2 = 1:15
A2 = 1×15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
r = 'AE';
[~,idx] = ismember(r,A1);
s = A2(idx)
s = 1×2
1 5

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by