How to generate an array based on the values of another array?

3 次查看(过去 30 天)
%Assign values ex: 2 becomes 4, 1 becomes 3, 3 becomes 2.....
A=[2 4;
1 3;
3 2;
4 1 ]
%Replace the new mappings at each position in the following array...ex:
B=[1 3;
3 1;
2 4;
4 3 ]
%New array generated C:
C=[3 2;
2 3;
4 1;
1 2 ]

采纳的回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2022-10-25
编辑:KALYAN ACHARJYA 2022-10-25
A=[1 3;3 1;2 4;4 3]
A = 4×2
1 3 3 1 2 4 4 3
B=A;
A(B==2)=4;
A(B==1)=3;
A(B==3)=2;
A(B==4)=1;
A
A = 4×2
3 2 2 3 4 1 1 2

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by