matlab - Find the count of elements in one matrix equal to another -



matlab - Find the count of elements in one matrix equal to another -

i need compare elements of 2 matrices , homecoming count of how many rows same. ismember function returns 1 column each column nowadays in matrix. want 1 column indicating whether row same or not. ideas appreciated.

if want compare corresponding rows of 2 matrices, use

result = all(a==b, 2);

example:

>> = [1 2; 3 4; 5 6] = 1 2 3 4 5 6 >> b = [1 2; 3 0; 5 6] b = 1 2 3 0 5 6 >> result = all(a==b, 2) result = 1 0 1

if want compare all pairs of rows:

result = pdist2(a,b)==0;

example:

>> = [1 2; 3 4; 1 2] = 1 2 3 4 1 2 >> b = [1 2; 3 0] b = 1 2 3 0 >> result = pdist2(a,b)==0 result = 1 0 0 0 1 0

matlab matrix

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -