Find array row element in another index array

1 回表示 (過去 30 日間)
AI-CHI Chang
AI-CHI Chang 2022 年 2 月 25 日
コメント済み: AI-CHI Chang 2022 年 2 月 25 日
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),:) ;
  1 件のコメント
AI-CHI Chang
AI-CHI Chang 2022 年 2 月 25 日
It works ! Thanks for your help !
I'll go and check how it works

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

その他の回答 (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