find a set of data in an array

조회 수: 9 (최근 30일)
mahsa momtahan
mahsa momtahan 2020년 1월 31일
댓글: Ridwan Alam 2020년 1월 31일
Hi everyone,
I have an array of repetitive values something like A=[0;0;396; ...;140;... ;403; 0 ;0 ;0 ;200; 140; ...;403; 0; 0 ] . I extracted non-zero set of data to another array, called B=[396; ...;140;... ;403 , 200; 140; ...;403]. Now, I want to find the index of each set of elements of array B from array A, but when I use '[tf,idx] = ismember (B,A)' , what is happening is that for those repeated elements the index is always the same as the index of first appeared one (idx for second 140 or 403 is the same of the idx of the first ones!). So, my question is that how can I find the indexes based on order ? or how can I find indexes when all the elements of array B's columns exactly repeated in array A?
Thanks,
Mahsa
  댓글 수: 1
Ridwan Alam
Ridwan Alam 2020년 1월 31일
maybe if you share your A and B and some sample code, it would be easier to help.

댓글을 달려면 로그인하십시오.

답변 (2개)

Ridwan Alam
Ridwan Alam 2020년 1월 31일
편집: Ridwan Alam 2020년 1월 31일
idx = find(A~=0);
B = A(idx);
idx and B have the same size and order. I believe this is what you are looking for?

mahsa momtahan
mahsa momtahan 2020년 1월 31일
No this won't work. I have a big data and as the exact time of appearing each element mattters, I cannot find out that the idx returned by 'idx = find(A~=0)' belongs to which elements (one data can be repeated so many times). I used regionprops(Data>Threshold, Data, 'PixelValues') to extract my data and need to find whole set of founded Pixelvalues in Data (for each i=1:xx, B(:,i) should be found in A).

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by