Find array row element in another index array

1 Ansicht (letzte 30 Tage)
AI-CHI Chang
AI-CHI Chang am 25 Feb. 2022
Kommentiert: AI-CHI Chang am 25 Feb. 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 ?

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by