I have one array(c ) of 30Kx15 sixe and one structure array(r.data), 25Kx19 size. Need to find rows with similiar coloumn data from both arrays and join them. in a particular order. Using the following code. But found its too time taking. Can someone suggest effiicient code please
k=1;
for i=1:length(r.data)
for j=1:length(cdataf)
if(r.data(i,3:9)==c(j,3:9))
finaldata(k,:)=[c(j,1:9) r.data(i,10:13) c(j,10:15)];
k=k+1;
end
end
end

댓글 수: 4

Walter Roberson
Walter Roberson 2021년 8월 26일
Look at ismember() with the 'rows' option.
Lakshmi Chodavarapu
Lakshmi Chodavarapu 2021년 8월 26일
편집: Lakshmi Chodavarapu 2021년 8월 26일
Many thanks Mr.Walter Roberson. Helped me a lot.
what about this tiny modification?
[loc, lor] = ismember(cdataf(:, 3:9), r.data(:, 3:9), 'rows');
rd = r.data(lor(loc), 3:9);
Lakshmi Chodavarapu
Lakshmi Chodavarapu 2021년 8월 26일
Many thanks. It worked out well. Grateful to you.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2021년 8월 26일

편집:

2021년 8월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by