finding indices of values in a range

2 ビュー (過去 30 日間)
sparsh garg
sparsh garg 2021 年 9 月 20 日
コメント済み: sparsh garg 2021 年 9 月 20 日
let's say you have a 2x300 matrix A,from that matrx,i select a sub array of dimension 2x24 whose range is as follows
[18 :41]
Now you have another matrix B which is an unordered version of the previous matrix.Meaning that value located at idnice 1 in A can be found in B at say 150.
How do i go about fidning at which indices do the values in the range of A occur in B
  1 件のコメント
sparsh garg
sparsh garg 2021 年 9 月 20 日
i tried using intersect but it didn't give me satisfactory results
for eg in the matrices shown below
the correct location of the values in query in the original matrix is
34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 80 82
similarly for query_2 the indices
are 33 35 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81

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

回答 (1 件)

KSSV
KSSV 2021 年 9 月 20 日
To achieve the first task, you can use inqualities i.e. >, <. = etc.
To achieve the second task use ismember.
  1 件のコメント
sparsh garg
sparsh garg 2021 年 9 月 20 日
so what you are saying is i first do [~,idx]=find(original_matrix==query_matrix),
but the original matrix has 2 duplicates for every value in query_matrix.

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by