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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by