m2016b
m2016b

Reputation: 544

Getting the mapping for a permutation in MATLAB

I have two binary matrix where one is a permutation of the other: How can I obtain the permutation mapping between both?

Example :

A=[1 0 1 0;1 1 0 0] 
B=[0 0 1 1;1 0 1 0]

A->B should be : [3 1 4 2]

Upvotes: 3

Views: 61

Answers (1)

rahnema1
rahnema1

Reputation: 15837

You can use second output of the ismember function

[~, out]=ismember(A.',B.','rows')

Upvotes: 3

Related Questions