Find array row element in another index array

3 次查看(过去 30 天)
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 ?

采纳的回答

KSSV
KSSV 2022-2-25
iwant = P(reshape(dx_of_pt',[],1),:) ;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by