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일

0 개 추천

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

댓글 수: 2

Desmond Chang
Desmond Chang 2022년 1월 23일
Thanks a lot!!!!
Voss
Voss 2022년 1월 23일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Language Support에 대해 자세히 알아보기

태그

질문:

2022년 1월 23일

댓글:

2022년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by