How to permute a row vector based on sepecfic method for permutation?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, suppose we have the matrix x,y,and z that is 1*28 dimension, I want to permute each one of them in this way:
x= [x(1,14),x(1,1), x(1,2), x(1,3), x(1,4), x(1,5), x(1,6),x(1,7), x(1,8),...
x(1,9), x(1,10), x(1,11), x(1,12), x(1,13), x(1,14),x(1,1), x(1,28), x(1,15),...
x(1,16), x(1,17), x(1,18), x(1,19), x(1,20), x(1,21), x(1,22), x(1,23), x(1,24), ...
x(1,25), x(1,26), x(1,27),x(1,28), x(1,15)];
So how can I do that also for y and z without repeating these lines for them also?
Regards,
0 commentaires
Réponse acceptée
David Goodmanson
le 14 Sep 2018
Modifié(e) : David Goodmanson
le 14 Sep 2018
Hi Sarah,
Since you have more than 28 elements in the final array I would not call it a permutation of elements, strictly speaking. Be that as it may, it makes sense work on an index.
ind = [14 1:14 1 28 15:28 15] % concatenate
xnew = x(1,ind);
ynew = y(1,ind);
znew = z(1,ind);
Since x,y,and z are row vectors and row 1 is the only possibility, you don't have to use the row index. In this case x(14) is the same as x(1,14). It's preferable to use
xnew = x(ind);
ynew = y(ind);
znew = z(ind);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Assembly dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!