同じ行を探し、インデックスを返す方法が知りたいです。
A=[1 2 3;2 3 1;3 2 1;1 3 2;1 2 3]
という行列の中から、
B=[1 2 3;3 2 1]
という行列と、行のみで見た場合に同じ数値のインデックス、つまり、
C=1行目、3行目、5行目という回答になるようにしたいのですが、よい方法が浮かびませんでした。
上記を実現するための関数はありますでしょうか?

 Respuesta aceptada

Voss
Voss el 21 de Feb. de 2022
Editada: Voss el 21 de Feb. de 2022

0 votos

A = [1 2 3; 2 3 1; 3 2 1; 1 3 2; 1 2 3];
B = [1 2 3; 3 2 1];
find(ismember(A,B,'rows'))
ans = 3×1
1 3 5

1 comentario

美紗子 馬渕
美紗子 馬渕 el 21 de Feb. de 2022
まさにやりたい内容を的確にご回答いただき、ありがとうございました。

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2021b

Etiquetas

Preguntada:

el 21 de Feb. de 2022

Comentada:

el 21 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!