Matrix element changes according to reference

1 回表示 (過去 30 日間)
ANAND ASP
ANAND ASP 2020 年 11 月 29 日
編集済み: Walter Roberson 2020 年 11 月 29 日
i have matrix Y and modify as ANS
Y=[ 11 12 13;
21 22 23;
31 32 33]
A=[1 1;
2 3;
3 2]
ANS=[ 11 13 12;
31 33 32;
21 23 22]
i have A matrix which indicates changes in matrix i.e., 1 is replace with 1, 2 is replace with 3 and 3 is replace with 2
according to that i want to change matrix Y to ANS. Change matrix elements using matrix A

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 11 月 29 日
編集済み: Walter Roberson 2020 年 11 月 29 日
Y=[ 11 12 13;
21 22 23;
31 32 33];
A=[1 1;
2 3;
3 2];
Y(A(:,2), A(:,2))
ans = 3×3
11 13 12 31 33 32 21 23 22

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by