search for a value in one matrix in another matrix

1 回表示 (過去 30 日間)
Berfin Çetinkaya
Berfin Çetinkaya 2022 年 3 月 29 日
コメント済み: Voss 2022 年 3 月 30 日
Hi everybody
Matrix A:
16 14 12 10 18
Matrix B:
2
3
5
4
1
new matrix :
2 14
3 12
5 18
4 10
1 16
For example, since 2 is written in matrix B, it prints the second row value in A next to 2 in the new matrix.
I need such a matrix. Could you help?
Thank u

採用された回答

Voss
Voss 2022 年 3 月 29 日
% Matrix A:
A = [16 14 12 10 18];
% Matrix B:
B = [2; 3; 5; 4; 1];
% new matrix :
new_matrix = [B A(B).']
new_matrix = 5×2
2 14 3 12 5 18 4 10 1 16
  5 件のコメント
Berfin Çetinkaya
Berfin Çetinkaya 2022 年 3 月 30 日
yes I meant that. Thanks a lot of.
Voss
Voss 2022 年 3 月 30 日
Excellent. You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by