Find array row element in another index array

2 visualizaciones (últimos 30 días)
AI-CHI Chang
AI-CHI Chang el 25 de Feb. de 2022
Comentada: AI-CHI Chang el 25 de Feb. de 2022
Given two array Idx_of_pt and P, I'd like to find all the row element in P from Idx_of_pt
Idx_of_pt=[1 2 3;4 6 7;2 3 5];
P=[-0.03 0.12 0.04
-0.94 0.12 0.01
-0.06 0.15 0.037
-0.22 0.13 0.02
-0.26 0.12 0.07
-0.25 0.16 0.62
-0.37 0.17 0.19 ]
so the result should be [-0.03 0.12 0.04 ; -0.94 0.12 0.01 ; -0.06 0.15 0.037
-0.22 0.13 0.02 ; -0.25 0.16 0.62 ; -0.37 0.17 0.19
-0.94 0.12 0.01 ; -0.06 0.15 0.037 ; -0.26 0.12 0.07]
(they can form triangles)
Any elegant method ?

Respuesta aceptada

KSSV
KSSV el 25 de Feb. de 2022
iwant = P(reshape(dx_of_pt',[],1),:) ;
  1 comentario
AI-CHI Chang
AI-CHI Chang el 25 de Feb. de 2022
It works ! Thanks for your help !
I'll go and check how it works

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by