Same number of zeros for a given number in the vector,
if there is a negative number in vector, then insert zeros to precede that number
For example:
x = [1 2 3 4 5]
y_correct = [1 0 2 0 0 3 0 0 0 4 0 0 0 0 5 0 0 0 0 0];
x = [1 -2 3 4 -5]
y_correct = [1 0 0 0 -2 3 0 0 0 4 0 0 0 0 0 0 0 0 0 -5];

Solution Stats

29 Solutions

14 Solvers

Last Solution submitted on Nov 07, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers14

Suggested Problems

More from this Author4

Problem Tags

Community Treasure Hunt

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

Start Hunting!