How to taker power of a permutaion matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
sadiqa ilyas
am 5 Okt. 2019
Bearbeitet: Bruno Luong
am 5 Okt. 2019
Hi ,I want to find the power of a permutation matrix, i.e
A=(1 2 3;3 2 1) is a permutation matrix and I want to find (1 2 3; 3 2 1)^5
.How to do this in matlab
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 5 Okt. 2019
Bearbeitet: Bruno Luong
am 5 Okt. 2019
You have 2 ways to compute it, from the permutation itself, or using the permutation matrix then raise a power of it.
% Generate a random test permutation
[~,p]=sort(rand(1,10)); % in you case it's [3 2 1], the second row of your A
% Permutation matrix
p0 = 1:length(p);
A = accumarray([p(:) p0(:)],1);
% raise power
n = 5;
Apn = A^n
% apply the permutation n times
pn = p0;
for k=1:n
pn = pn(p);
end
An = accumarray([pn(:) p0(:)],1)
% Check both gives the same result
isequal(Apn,An)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Semiconductors and Converters finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!