How to match elements of matrix having different dimensions?
이전 댓글 표시
if true
% code
endI have some dates in say variable A as 10x6 double form :
2000 01 01 00 00 01
2000 01 01 00 00 02
2000 01 01 00 00 03
...
...
...
2000 01 01 00 00 09
2000 01 01 00 00 10
Now another matrix B as 5x6 double form :
2000 01 01 00 00 01
2000 01 01 00 00 02
2000 01 01 00 00 03
2000 01 01 00 00 09
2000 01 01 00 00 10
Now i would like to find the row index of A where elements of B are found. i.e. answer = row index: 1,2,3,9,10.
I tried
idx = ismember(A, B,'rows'); % it does not work!
so i tried,
idx = ismember(B, A,'rows'); % which also does not work!
So i used conventional hour-taking method:
% tic
% idx = nan(length(A),1);
% for i = 1:A
% for j = 1:B
% if isequal(A(i,:), B(j,:))
% idx(i,1) = j;
% end
% end
% end
% toc
Any short-cut to solve this...?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!