Raise the zeros in the vector up

1 回表示 (過去 30 日間)
Eran Shvartzman
Eran Shvartzman 2017 年 12 月 15 日
コメント済み: Eran Shvartzman 2017 年 12 月 16 日
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.

採用された回答

KL
KL 2017 年 12 月 15 日
Something like this,
v = [5 8 0 7 9 0 3]
ind = v==0;
v = [v(ind) v(~ind)]
  1 件のコメント
Eran Shvartzman
Eran Shvartzman 2017 年 12 月 16 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by