MATLAB Answers

Raise the zeros in the vector up

3 views (last 30 days)
Eran Shvartzman
Eran Shvartzman on 15 Dec 2017
Commented: Eran Shvartzman on 16 Dec 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.

  0 Comments

Sign in to comment.

Accepted Answer

KL
KL on 15 Dec 2017
Something like this,
v = [5 8 0 7 9 0 3]
ind = v==0;
v = [v(ind) v(~ind)]

  1 Comment

Eran Shvartzman
Eran Shvartzman on 16 Dec 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

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags