How to swap row elements by increasing and decresing order.

1 vue (au cours des 30 derniers jours)
Triveni
Triveni le 22 Jan 2016
Commenté : Triveni le 22 Jan 2016
p = [30 30 30 30 30 30 0 0 0 0 0 0 0 0 30 30 30 30 30 30]
I want to swap it like [30 30 30 30 30 30 30 30 30 30 30 30 0 0 0 0 0 0 0 0];
Np = length(M);
for p = Np/2: -1:2
for CP = p-1:-1:1
if M(1,CP) ~= M(1,CP+1)
M(1,CP) = M(1,CP+1)
end
end
end

Réponse acceptée

Walter Roberson
Walter Roberson le 22 Jan 2016
sort(p, 'descending')
  2 commentaires
Triveni
Triveni le 22 Jan 2016
sort(p, 'descend')
Thanks
Triveni
Triveni le 22 Jan 2016
Can you generate it by algorithm which i've tried??? by swap & interchange , store generated swaps.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Arduino Hardware dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by