G=[1 0]with I={[1 0;1 1;0 0;1 0;1 1;0 1;1 0 random sequence]} i need to compare them and count number of matched bits

답변 (2개)

the cyclist
the cyclist 2011년 7월 23일

0 개 추천

You can use the ismember() command, with the 'rows' option.

댓글 수: 3

mahaveer hanuman
mahaveer hanuman 2011년 7월 23일
actually g(1x2)and I(45x2)row wise compare.please help
the cyclist
the cyclist 2011년 7월 23일
Fangjun Jiang has kindly written the exact code you need. What's the problem?
Andrei Bobrov
Andrei Bobrov 2011년 7월 23일
arrayfun(@(j1)isequal(I(j1,:),G),(1:size(I,1))')

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

Fangjun Jiang
Fangjun Jiang 2011년 7월 23일

0 개 추천

Probably there is no need to make I a cell array.
G=[1 0];
I=[1 0;1 1;0 0;1 0;1 1;0 1;1 0];
Compare=ismember(I,G,'rows');
Count=sum(Compare)

댓글 수: 2

mahaveer hanuman
mahaveer hanuman 2011년 7월 23일
G(1x2)and I(45X2) so now how can i compare
Fangjun Jiang
Fangjun Jiang 2011년 7월 23일
Put in your G and I and follow the code. I've modified the code.

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2011년 7월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by