Azzera filtri
Azzera filtri

Raise the zeros in the vector up

1 visualizzazione (ultimi 30 giorni)
Eran Shvartzman
Eran Shvartzman il 15 Dic 2017
Commentato: Eran Shvartzman il 16 Dic 2017
If I have a vector [5 8 0 7 9 0 3], how do I put it this way: [0 0 5 8 7 9 3] use only function if-else
thank you.

Risposta accettata

KL
KL il 15 Dic 2017
Something like this,
v = [5 8 0 7 9 0 3]
ind = v==0;
v = [v(ind) v(~ind)]
  1 Commento
Eran Shvartzman
Eran Shvartzman il 16 Dic 2017
Thanks! But if I want it to work for any vector / matrix?
For example: [5 8 0 7 9 0 3] ' it will not work

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by