This solution is outdated. To rescore this solution, sign in.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
x = [1 2 3 4 5];
n=2;
y_correct = [1 0 0 2 0 0 3 0 0 4 0 0 5 0 0];
assert(isequal(insert_zeros(x,n),y_correct))
ans =
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ans =
1 0 0 2 0 0 3 0 0 4 0 0 5 0 0
|
2 | Pass |
%%
x = [1 2 3 4 5];
n=1;
y_correct = [1 0 2 0 3 0 4 0 5 0 ];
assert(isequal(insert_zeros(x,n),y_correct))
ans =
0 0 0 0 0 0 0 0 0 0
ans =
1 0 2 0 3 0 4 0 5 0
|
3 | Pass |
%%
x = [1 2];
n=5;
y_correct = [1 0 0 0 0 0 2 0 0 0 0 0];
assert(isequal(insert_zeros(x,n),y_correct))
ans =
0 0 0 0 0 0 0 0 0 0 0 0
ans =
1 0 0 0 0 0 2 0 0 0 0 0
|
How to find the position of an element in a vector without using the find function
2317 Solvers
1874 Solvers
07 - Common functions and indexing 4
258 Solvers
211 Solvers
683 Solvers