Compare two different length vectors

2 次查看(过去 30 天)
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