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

Risposte (2)

the cyclist
the cyclist il 23 Lug 2011

0 voti

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

3 Commenti

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

Accedi per commentare.

Fangjun Jiang
Fangjun Jiang il 23 Lug 2011

0 voti

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 Commenti

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

Accedi per commentare.

Categorie

Tag

Richiesto:

il 23 Lug 2011

Community Treasure Hunt

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

Start Hunting!

Translated by