Same value in two different matrices with different properties.

2 ビュー (過去 30 日間)
Joel Schelander
Joel Schelander 2021 年 4 月 30 日
回答済み: Sindhu Karri 2021 年 5 月 6 日
I have one matrix A an a matrix B. I want to create matrix C. matrix has the same size of A, but with numbers from B.
A=[987 583;476 232;650 102];
B=[987 1;583 2;476 1; 232 3; 650 4; 102 5];
%The matrox I want to create looks like this
C=[1 2;1 3;4 5]

採用された回答

Sindhu Karri
Sindhu Karri 2021 年 5 月 6 日
Hii,
Hope below attached code helps
A=[987 583;476 232;650 102];
B=[987 1;583 2;476 1; 232 3; 650 4; 102 5];
C=zeros(size(A));
d=numel(A);
for i=1:d
index=find(B==A(i));
C(i)=B(index+d);
end
Refer to below links

その他の回答 (0 件)

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by