Cody

# Problem 1958. Add a row of zeros on top of a matrix

Solution 2053362

Submitted on 10 Dec 2019 by Maklári-Klekner Tamás Pál
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = rand(4); y_correct = [zeros(1,size(x,2));x]; assert(isequal(addrow(x),y_correct))

k = 4 y = 0 0 0 0 0.2944 0.5523 0.0850 0.4021 0.4462 0.1114 0.1767 0.8613 0.6691 0.5942 0.3215 0.2586 0.3426 0.3193 0.1300 0.2997

2   Pass
x = []; y_correct = zeros(1,0); assert(isequal(addrow(x),y_correct))

k = 0 y = 1×0 empty double row vector

3   Pass
x = rand(8,1); y_correct = [zeros(1,size(x,2));x]; assert(isequal(addrow(x),y_correct))

k = 1 y = 0 0.6214 0.0504 0.5101 0.0549 0.4127 0.1248 0.1588 0.2077

4   Pass
x = zeros(0,1); y_correct = 0; assert(isequal(addrow(x),y_correct))

k = 1 y = 0

### Community Treasure Hunt

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

Start Hunting!