What does permute actually produce?
Afficher commentaires plus anciens
Trying some calculations earlier, I have realised permute does not do what I thought it did. To clarify I did this
% code
test = rand(4,4,4,4) + rand(4,4,4,4)*1i;
test2a = zeros(4,4,4,4); test2b = zeros(4,4,4,4);
for a = 1:4
for b = 1:4
for c = 1:4
for d = 1:4
test2a(a,b,c,d) = test(a,b,d,c);
test2b(a,b,c,d) = test(b,a,c,d);
end
end
end
end
test3a = permute(test,[1,2,4,3]);
test3b = permute(test,[2,1,3,4]);
m1=max(test2a(:)-test3a(:))
m2=max(test2b(:)-test3b(:))
test2a = zeros(4,4,4,4); test2b = zeros(4,4,4,4);
for a = 1:4
for b = 1:4
for c = 1:4
for d = 1:4
test2a(a,b,c,d) = test(d,b,a,c);
test2b(a,b,c,d) = test(c,a,b,d);
end
end
end
end
test3a = permute(test,[4,2,1,3]);
test3b = permute(test,[3,1,2,4]);
m3=max(test2a(:)-test3a(:))
m4=max(test2b(:)-test3b(:))
m1 =
0
m2 =
0
m3 =
0.9525 + 0.5183i
m4 =
0.9293 - 0.7266i
clearly the first is the same but the latter is different. Is there some way to create the second variables (of form test2(a,b,c,d) == test(d,b,a,c) which involve two permutations ) just using permute on test?
1 commentaire
David H
le 20 Nov 2014
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!