compare

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 个评论

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 个评论

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 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by