finding indices of values in a range

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by