finding in which row two array has equal values
조회 수: 13 (최근 30일)
이전 댓글 표시
I have two array with different length A=(500.000,1) and B=(621,1) where all the 621 values of B are included in some of the A rows.
I want to find in which row of A, B will have the same value of A and create a new array C with the result(index)
any idea?
댓글 수: 2
madhan ravi
2019년 4월 17일
편집: madhan ravi
2019년 4월 17일
Illustrate with a short example. See if ismember() does what you want.
채택된 답변
Adam Danz
2019년 4월 17일
편집: Adam Danz
2019년 4월 17일
% Create fake data for the example
B = 1:621;
A = randi(621, 500000, 1);
% Loop through each element of B, return the row number of matching values in A
resultIdx = cell(size(B));
for i = 1:length(B)
resultIdx{i} = find(ismember(A,B(i)));
end
resultIdx{n} lists the rows of A that match the value of B(n).
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!