# How to find the reverse of a permutation vector?

40 visualizzazioni (ultimi 30 giorni)
Po-Yu (Paul) Chen il 4 Lug 2013
Risposto: Jovana Dzunic il 17 Nov 2019
Dear all,
I have a permutation vector
p = [1 3 2 4];
and I define its corresponding permutation matrix is
P = [1 0 0 0 ; 0 0 1 0 ; 0 1 0 0 ; 0 0 0 1 ]; Then the transpose of P is P' = P.
So what's the corresponding permutation vector of P', said pt?
In this case, pt = p since P' = P.
So, are there any fast way (matlab function) to compute permutation vector pt for a given p, for more general case?
Thanks
Paul
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Jan il 4 Lug 2013
Do you want this:
p = [1 3 2 4];
pt(p) = 1:length(p);
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Po-Yu (Paul) Chen il 4 Lug 2013
Thanks Jan ^^

Accedi per commentare.

### Più risposte (2)

Jovana Dzunic il 17 Nov 2019
Try this code
zerop=1:4;
p=[1,3,2,4];
invp(p)=zerop(1:4)
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Hugo il 4 Lug 2013
Notice that
p = P * (1:4)'
The same for pt, i.e.
pt = P' * (1:4)'
For vectors p of length N, just use:
pt= P' * (1:N)'
The transpose in (1:N)' is only there to ensure that (1:N) is a column vector.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by