Compare two different length vectors

조회 수: 3 (최근 30일)
jano satti
jano satti 2017년 4월 12일
답변: Star Strider 2017년 4월 12일
let say A=[2 3] and B=[3 3 2] and c=[ 10 20],now A compares the elements with B and assign values from c. Answer is D=[20 20 10] How can I do that? Thanks in Advance.

채택된 답변

Star Strider
Star Strider 2017년 4월 12일
Use the second output of the ismember function:
A=[2 3];
B=[3 3 2];
C=[ 10 20];
[~,idx] = ismember(B,A);
D = C(idx)
D =
20 20 10

추가 답변 (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