MATLAB Answers

0

How to from I(x) to permutation and from permutation to I(x)

Asked by hang dong on 22 May 2019
Latest activity Commented on by madhan ravi
on 22 May 2019
I have the following table:
I Permutation
0 0 1 2 3
1 0 2 3 1
2 0 3 1 2
.......
22 3 2 0 1
23 3 2 1 0
How to from I(x) to permutation and from permutation to I(x)
Exam I(2) -> Per (0 3 1 2)
per(3 2 0 1) -> I(22)
help me!

  2 Comments

What are your inputs? and what is your desired output? Illustrate with an explicit example.

Sign in to comment.

1 Answer

Answer by James Tursa
on 22 May 2019
Edited by James Tursa
on 22 May 2019

E.g.,
>> Per
Per =
0 1 2 3
0 2 3 1
0 3 1 2
3 2 0 1
3 2 1 0
>> p
p =
0 3 1 2
>> x = find(ismember(Per,p,'rows'))
x =
3
>> Per(x,:)
ans =
0 3 1 2
>> q = [3 2 0 1]
q =
3 2 0 1
>> x = find(ismember(Per,q,'rows'))
x =
4
>> Per(x,:)
ans =
3 2 0 1

  4 Comments

Show 1 older comment
Huh? What is table A and table B?
haiz.PNG
q = [ 0 1 2 3 5 4]
x = find(ismember(T,q,'rows'))
error. help me!
Table A include column I and Per
Table B include column Per
How to use ismember statements?

Sign in to comment.